A web application built with Node.js that allows users to manage their tasks. Users can create, edit, delete, and mark their tasks as completed. Admins have additional permissions to manage tasks for any user.
-
User:
- Create tasks
- Edit tasks
- Delete tasks
- Mark tasks as completed
-
Admin:
- Manage tasks for any user (CRUD operations)
- View all users and their tasks
- Delete users
- Backend: Node.js, Express.js
- Database: MySQL
- Authentication: JWT (JSON Web Tokens) & bcrypt
- Security: Helmet, express-rate-limit
- Input Validation: Validator
To get this project running locally, follow these steps:
- Node.js (v14.x or above)
- MySQL
-
Clone the repository:
git clone https://github.com/kxng0109/node-task-management-system.git cd node-task-management-system
-
Install dependencies:
npm install
-
Set up environment variables: Create a .env file in the root directory of your project and include the following:
DB_HOST=database_host DB_USER=the_user DB_PASSWORD=your_database_password JWT_SECRET=your_jwt_secret_key JWT_EXPIRE=jwt_expiration_time BCRYPT_SALT=bcrypt_salt PORT=3000
Replace the_user, the_password, database_host, and your_jwt_secret_key with your own local values. Also feel free to replace the PORT and BCRYPT_SALT values to any custom value. For more information about bcryptjs salt, visit their official docummentation
-
Run the application:
npm start
The app will run on http://localhost:3000 by default, unless the "PORT" value is changed.
Base URL: /api
Method | Endpoint | Description |
---|---|---|
POST | /register |
Register a new user. |
POST | /login |
User login. |
POST | /admin/register |
Register a new admin. |
POST | /admin/login |
Admin login. |
Note: email and password are required for login and registration
Base URL: /api/admin
Method | Endpoint | Description |
---|---|---|
DELETE | /delete/:id |
Delete a user by their ID. |
GET | /tasks |
Get all tasks. |
POST | /tasks |
Create a new task. |
DELETE | /tasks/:id |
Delete a task by its ID. |
PATCH | /tasks/:id |
Update a task by its ID. |
Base URL: /api/tasks
Method | Endpoint | Description |
---|---|---|
GET | / |
Get all tasks for the authenticated user. |
POST | / |
Create a new task for the authenticated user. |
PATCH | /:id |
Update a task by its ID for the authenticated user. |
DELETE | /:id |
Delete a task by its ID for the authenticated user. |
Note: To create a task, user_id, title, description and deadline are required in that order. Note: To update a task, "completed" is required.
This project is licensed under the MIT License - see the LICENSE file for details.