Exercises
Task 1: Simple Todo List API
This task involves building a basic API for managing a list of tasks.
-
GET /tasks
Fetch all tasks from the array. -
GET /tasks/:id
Fetch a specific task by its ID. -
POST /tasks
Add a new task to the array. -
PUT /tasks/:id
Update the details of a specific task using its ID. -
DELETE /tasks/:id
Remove a task from the array by its ID. -
DELETE /tasks
Remove all tasks from the array.
Task2 : User Authentication and Profile Management
Build a simple user authentication and profile management API with the following endpoints and functionality:
Endpoints:
-
POST /users/register
Create a new user with attributes likeusername,password, andemail. -
POST /users/login
Authenticate a user by checking theirusernameandpassword. -
GET /users
Retrieve the list of all users (accessible by admins only). -
GET /users/:id
Retrieve details of a specific user by their ID. -
PUT /users/:id
Update the details of a specific user. -
DELETE /users/:id
Delete a specific user account.
Requirements:
-
Password Hashing:
Usebcryptto hash user passwords before saving them to the database. -
Login Functionality:
Implement a basic login feature (without JWT or sessions) that validates the username and password. -
Role-Based Access:
Include arolefield (e.g.,admin,user) to enable role-based access to certain endpoints likeGET /users.
Task 3: User Management API
-
GET /users
Create an array of users and fetch all the users in the array. -
GET /users/:id
Fetch a specific user from the array using their ID. -
POST /users
Add a new user to the array. -
PUT /users/:id
Update the details of a specific user in the array using their ID. -
DELETE /users
Remove all users from the array.