A RESTful API built with Node.js and Express, designed to manage users and their tasks.
This project was developed as part of my Node.js learning journey and includes features like authentication, file uploads, and database integration with MongoDB.
-
User Management
- Register new users
- Login / Logout
- Update and delete user profile
- Authentication using JWT
- Password hashing for security
-
Task Management
- Create new tasks
- Read tasks (with filtering, pagination, and sorting)
- Update tasks
- Delete tasks
-
File Upload
- Upload and manage user profile avatars (with validation)
- Backend: Node.js, Express.js
- Database: MongoDB, Mongoose
- Authentication: JWT (JSON Web Token), bcrypt.js
- Email Service: SendGrid
- File Upload: Multer
- Testing: Jest, Supertest
task-manager/
│-- src/
│ │-- db/ # Database connection
│ │-- middleware/ # Authentication middleware
│ │-- models/ # User and Task models
│ │-- routers/ # Express route handlers
│ │-- emails/ # SendGrid email functions
│ |-- app.js
| └-- index.js # App entry point
|
│-- tests/ # Testing using jest
│-- .env # Environment variables
│-- package.json # Dependencies and scripts
└-- README.md
- Clone the repository
git clone https://github.com/<your-username>/task-manager-nodeJS.git cd task-manager-nodeJS
- Install dependencies
npm install
- Setup environment variables
Create a dev.env and test.env file in the root folder and add with different database name in test.env:
PORT=3000 MONGODB_URL=mongodb://127.0.0.1:27017/task-manager-api JWT_SECRET=your_jwt_secret SENDGRID_API_KEY=your_sendgrid_api_key
- Run the project
npm run dev
-
👤 Users
- POST /users → Register a new user
- POST /users/login → Login user
- POST /users/logout → Logout user
- GET /users/me → Get logged-in user profile
- PATCH /users/me → Update user profile
- DELETE /users/me → Delete user account
-
✅ Tasks
- POST /tasks → Create a task
- GET /tasks → Get all tasks (with filtering, sorting, pagination)
- GET /tasks/:id → Get task by ID
- PATCH /tasks/:id → Update task
- DELETE /tasks/:id → Delete task
- Node.js + Express → Server & API
- MongoDB + Mongoose → Database
- JWT (jsonwebtoken) → Authentication
- Multer → File uploads
- SendGrid → Email service
- bcryptjs → Password hashing
- Jest + Supertest → testing
This project includes automated tests written with the Jest framework.
All major endpoints for Users and Tasks have been tested to ensure reliability.
- Tests are located in the
/tests
folder. - Includes unit tests and integration tests for:
- User authentication & profile management
- Task creation, update, retrieval, and deletion
- Uses
supertest
for API endpoint testing.
npm test