Task-Manager-Api is a robust and scalable web backend solution built with Node.js, Express, and Mongoose. This API provides a comprehensive suite of features for user management, task operations, and secure authentication, making it an ideal foundation for task management applications.
- User authentication and authorization
- CRUD operations for tasks
- User profile management including avatar uploads
- Email notifications for account actions
- Secure API endpoints with JWT authentication
- Node.js (v14+): JavaScript runtime for server-side development
- Express (v4.17+): Web application framework for Node.js
- Mongoose (v5.12+): MongoDB object modeling tool
- JSON Web Token (jsonwebtoken v8.5+): Implementation of JSON Web Tokens for secure authentication
- Bcrypt (v5.0+): Library for hashing passwords
- Multer (v1.4+): Middleware for handling multipart/form-data, used for file uploads
- Postmark (v2.7+): Email delivery service for transactional emails
- MongoDB (v4.4+): NoSQL database for storing user and task data
- Node.js (v14 or later)
- MongoDB (v4.4 or later)
- npm (v6 or later)
- Clone the repository:
git clone https://github.com/yourusername/task-manager-api.git
- Navigate to the project directory:
cd task-manager-api
- Install dependencies:
npm install
- Set up environment variables:
Create a
.env
file in the root directory and add the following variables:PORT=3000 MONGODB_URL=mongodb://localhost:27017/task-manager-api JWT_SECRET=your_jwt_secret POSTMARK_API_KEY=your_postmark_api_key
- Start the server:
npm run start
POST /users
: Create a new user accountPOST /users/login
: User loginPOST /users/logout
: User logout (requires authentication)POST /users/logoutAll
: Logout from all devices (requires authentication)GET /users/me
: Retrieve current user profile (requires authentication)PATCH /users/me
: Update user profile (requires authentication)DELETE /users/me
: Delete user account (requires authentication)
POST /users/me/avatar
: Upload user avatar (requires authentication)DELETE /users/me/avatar
: Delete user avatar (requires authentication)GET /users/:id/avatar
: Retrieve user avatar by ID
POST /tasks
: Create a new task (requires authentication)GET /tasks
: Retrieve all tasks for the authenticated user (requires authentication)GET /tasks/:id
: Retrieve a specific task by ID (requires authentication)PATCH /tasks/:id
: Update a specific task (requires authentication)DELETE /tasks/:id
: Delete a specific task (requires authentication)
The API uses JSON Web Tokens (JWT) for authentication. Include the JWT in the Authorization
header of your requests:
Authorization: Bearer <your_jwt_token>
name
: String (required)email
: String (required, unique)password
: String (required, min length: 7)age
: Numbertokens
: Array of JWT tokensavatar
: Buffer for storing avatar image
description
: String (required)completed
: Boolean (default: false)owner
: ObjectId (reference to User model)
The API sends transactional emails using Postmark for the following events:
- Welcome email upon account creation
- Cancellation email when a user deletes their account