Skip to content

[JITERA] Implement ToDo API with CRUD operations

chi le requested to merge feat/todo-api-implementation-1759160087 into main

Created by: chi-jitera

Overview

This pull request implements a complete ToDo API, including the controller, service, routes, and integration into the main application. The API allows for the creation, retrieval, updating, patching, and deletion of ToDo items.

Changes

  1. Controller (controllers/todoController.js):

    • Created a controller to handle incoming requests for ToDo items.
    • Implemented methods for creating, retrieving, updating, patching, and deleting ToDo items.
    • Each method handles errors and responds with appropriate status codes and messages.
  2. Service (services/todoService.js):

    • Created a service layer to encapsulate the business logic for ToDo operations.
    • Implemented validation for ToDo data to ensure that the title is a string and required, and that the due date is a valid date.
    • Provided methods for interacting with the ToDo model, including creating, retrieving, updating, patching, and deleting ToDo items.
  3. Routes (routes/todoRoutes.js):

    • Defined routes for the ToDo API, mapping HTTP methods to the corresponding controller methods.
    • Included routes for all CRUD operations.
  4. App Integration (app.js):

    • Updated the main application file to include the ToDo routes.
    • Ensured that the application can handle requests to the ToDo API alongside existing routes.

This implementation follows best practices for error handling and response formatting, returning a consistent structure for success and error responses.

Merge request reports