A simple RESTful API for managing tasks with authentication, built using Node.js, Express, and MongoDB.
- User authentication (Sign-Up, Login, Logout)
- Task management (CRUD operations)
- Status tracking for tasks (pending, In progress, completed)
- Middleware for authentication and authorization
- Error handling for consistent API responses
- After logging users will automatically be redirected to the dashboard page(All tasks page) they will be able to see their tasks as being created and listed and have the option to add a new task, view all tasks, update a task, and delete a task.
Endpoint | Method | Description | Body | Requires Auth |
---|---|---|---|---|
/auth/signup | POST | Register a user | { "username": "git", "password": "pass123" } |
No |
/auth/login | POST | User login | { "username": "github", "password": "pass123" } |
No |
/auth/logout | POST | User logout | Yes |
Endpoint | Method | Description | Body | Requires Auth |
---|---|---|---|---|
/tasks | POST | Create a new task | { "title": "Task Title", "description": "Details", "status": "pending" } |
Yes |
/tasks/:id | PUT | Update a task | { "title": "", "description": "", "status": "pending/In progress/completed" } |
Yes |
/tasks/:id | DELETE | Delete a task | N/A | Yes |
Clone the repository:
git clone https://github.com/Abiodun001-world/todo-app
cd todo-app
Install dependencies:
npm install
Create a .env
file in the root directory:
PORT=
MONGO_URI=
JWT_SECRET=
Start the development server:
npm run dev
You can use tools like Postman or Insomnia to test the API endpoints.
-
User Registration:
- Endpoint:
POST /auth/signup
- Body:
{ "username": "test", "password": "pass123" }
- Endpoint:
-
User Login:
- Endpoint:
POST /auth/login
- Body:
{ "username": "test", "password": "pass123" }
- Endpoint:
-
Create a Task:
- Endpoint:
POST /tasks
- Body:
{ "title": "Task Title", "description": "Details", "status": "pending" }
- Requires Auth: Yes (Include the token in the headers)
- Endpoint:
-
Get All Tasks by user id:
- Endpoint:
GET /tasks
- Requires Auth: Yes (Include the token in the headers)
- Endpoint:
-
Get a Specific Task by a task id:
- Endpoint:
GET /tasks/:id
- Requires Auth: Yes (Include the token in the headers)
- Endpoint:
-
Update a Task by a task id:
- Endpoint:
PUT /tasks/:id
- Body:
{ "title": "Task Title", "description": "Task Title", "status": "pending/In progress/completed" }
- Requires Auth: Yes (Include the token in the headers)
- Endpoint:
-
Delete a Task:
- Endpoint:
DELETE /tasks/:id
- Requires Auth: Yes (Include the token in the headers)
- Endpoint:
Access the live application here