TaskPro is a backend service developed for task and user management. The project is built with Node.js, Express.js, and MongoDB. It includes modern backend features such as JWT-based authentication, session management, file uploads, and theme support.
- TaskPro Backend
-
Clone the repository:
git clone https://github.com/leventkoybasi/taskpro-backend.git cd taskpro-backend -
Install dependencies:
npm install
-
Set up environment variables: Copy
.env.exampleto.envand fill in the required fields.
The following environment variables are required:
PORTAPP_DOMAINMONGODB_USER,MONGODB_PASSWORD,MONGODB_URL,MONGODB_DBJWT_SECRETSMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASSWORDCLOUDINARY_CLOUD_NAME,CLOUDINARY_API_KEY,CLOUDINARY_API_SECRETGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,GOOGLE_REDIRECT_URI
See .env.example for details.
npm run devor
npm start| Method | Route | Description |
|---|---|---|
| POST | /register |
Register a new user |
| POST | /login |
User login |
| POST | /refresh |
Refresh JWT token |
| POST | /logout |
Logout and end session |
Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "yourPassword"
}Response:
{
"user": {
"id": "userId",
"name": "John Doe",
"email": "john@example.com",
"theme": "light"
},
"accessToken": "jwt-access-token"
}Request Body:
{
"email": "john@example.com",
"password": "yourPassword"
}Response:
{
"user": {
"id": "userId",
"name": "John Doe",
"email": "john@example.com",
"theme": "light"
},
"accessToken": "jwt-access-token"
}Request:
Refresh token and sessionId are sent via cookies.
Response:
{
"accessToken": "new-jwt-access-token"
}Request:
Refresh token and sessionId are sent via cookies.
Response:
{
"message": "Logged out successfully"
}| Method | Route | Description |
|---|---|---|
| GET | / |
Get all users |
| GET | /:userId |
Get user by ID |
| POST | / |
Create a new user |
| PATCH | /:userId |
Update user |
| DELETE | /:userId |
Delete user |
Response:
[
{
"id": "userId",
"name": "John Doe",
"email": "john@example.com",
"theme": "light"
}
]Response:
{
"id": "userId",
"name": "John Doe",
"email": "john@example.com",
"theme": "light"
}Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "yourPassword"
}Response:
{
"id": "userId",
"name": "John Doe",
"email": "john@example.com",
"theme": "light"
}Request Body:
{
"name": "Jane Doe",
"theme": "dark"
}Response:
{
"id": "userId",
"name": "Jane Doe",
"email": "john@example.com",
"theme": "dark"
}Response:
{
"message": "User deleted"
}- JWT-based authentication is used.
- Session records are kept with access and refresh tokens.
- For login and token refresh, refresh token and sessionId are sent via cookies.
- Users are created with name, email, password, avatar, and theme.
- Passwords are hashed with bcrypt.
- Theme can be
light,dark, orviolet.
- On each login, old sessions are deleted and a new session is created.
- When the token expires, it can be refreshed via
/auth/refresh. - On logout, the session and cookies are cleared.
- Swagger UI is available for API documentation.
- To generate documentation:
npm run build-docs
- Then access via
/docs/swagger.jsonor the relevant endpoint.
To generate the OpenAPI documentation (swagger.json) using Redocly, run:
npm run build-docsThis will bundle your OpenAPI YAML file (docs/openapi.yaml) into a JSON file (docs/swagger.json).
To preview the documentation locally in your browser, run:
npm run preview-docs- The project uses ESLint for code standards.
- Code formatting rules are defined in
.prettierrc. - All code is written in modern ES6+ syntax.
Please fork the repository and submit a pull request. Run linter and tests before submitting your code.
ISC