Skip to content

Exercises

Task 1: Simple Todo List API

This task involves building a basic API for managing a list of tasks.

  1. GET /tasks
    Fetch all tasks from the array.

  2. GET /tasks/:id
    Fetch a specific task by its ID.

  3. POST /tasks
    Add a new task to the array.

  4. PUT /tasks/:id
    Update the details of a specific task using its ID.

  5. DELETE /tasks/:id
    Remove a task from the array by its ID.

  6. 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 like username, password, and email.

  • POST /users/login
    Authenticate a user by checking their username and password.

  • 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:

  1. Password Hashing:
    Use bcrypt to hash user passwords before saving them to the database.

  2. Login Functionality:
    Implement a basic login feature (without JWT or sessions) that validates the username and password.

  3. Role-Based Access:
    Include a role field (e.g., admin, user) to enable role-based access to certain endpoints like GET /users.


Task 3: User Management API

  1. GET /users
    Create an array of users and fetch all the users in the array.

  2. GET /users/:id
    Fetch a specific user from the array using their ID.

  3. POST /users
    Add a new user to the array.

  4. PUT /users/:id
    Update the details of a specific user in the array using their ID.

  5. DELETE /users
    Remove all users from the array.