A RESTful API built with Node.js, Express.js, and MongoDB to manage tasks collaboratively. Includes user registration, authentication (JWT), and task CRUD with filtering and pagination.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB + Mongoose
- Auth: JWT (jsonwebtoken)
- Security: bcrypt, helmet, input sanitization
- Validation: express-validator
- Testing: Postman
task-manager-api/ ├── controllers/ ├── models/ ├── routes/ ├── middlewares/ ├── validations/ ├── config/ ├── .env.example ├── app.js ├── server.js └── README.md
user endpoints
http://localhost:5000/api/auth/login
--> curl --location 'http://localhost:5000/api/auth/login'
--header 'Content-Type: application/json'
--data-raw '{
"email": "sagar@gmail.com",
"password": "sagar@123"
}'
http://localhost:5000/api/auth/register
curl --location 'http://localhost:5000/api/auth/register'
--header 'Content-Type: application/json'
--data-raw '{
"name":"Sagar",
"email": "sagar@gmail.com",
"password": "sagar@123"
}'
-> get task
curl --location 'http://localhost:5000/api/tasks'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4NWFkNzRiYzVlNDRkNjJhOGI1YjgyMyIsImlhdCI6MTc1MDc4NDE1MCwiZXhwIjoxNzUwODcwNTUwfQ.O3MNNTEyjnOCo5am0UQWxJ0X_qRKUqf3xfz_VePQ1j0'
-> create task
curl --location 'http://localhost:5000/api/tasks'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4NWFkNzRiYzVlNDRkNjJhOGI1YjgyMyIsImlhdCI6MTc1MDc4NDE1MCwiZXhwIjoxNzUwODcwNTUwfQ.O3MNNTEyjnOCo5am0UQWxJ0X_qRKUqf3xfz_VePQ1j0'
--data '{
"title":"Demo",
"description":"sdhkjsdhsjdhjsd",
"assignedTo":"685ad9ed269e1c62f21195c3"
}'
-> update task
curl --location --request PUT 'http://localhost:5000/api/tasks/685ada09269e1c62f21195c5'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4NWFkOWVkMjY5ZTFjNjJmMjExOTVjMyIsImlhdCI6MTc1MDc4NDU1OCwiZXhwIjoxNzUwODcwOTU4fQ.csc2A1UPm5Qran7aCg5ls-5WqkpEW-tK7XcdC65Y_Vw'
--data '{
"status":"done"
}'
-> delete task
curl --location --request DELETE 'http://localhost:5000/api/tasks/685ada09269e1c62f21195c5'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4NWFkOWVkMjY5ZTFjNjJmMjExOTVjMyIsImlhdCI6MTc1MDc4NDU1OCwiZXhwIjoxNzUwODcwOTU4fQ.csc2A1UPm5Qran7aCg5ls-5WqkpEW-tK7XcdC65Y_Vw'
PORT = 5000 MONGO_URI = mongodb://localhost:27017/mcs-task JWT_SECRET = thisisstrongjwtsecretforloginsession