Skip to content

[JITERA] Implement ToDo API

chi le requested to merge feat/todo-api-implementation-1759160147 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 creating, retrieving, updating, patching, and deleting ToDo items.

Changes Made

  1. Controller (controllers/todoController.js):

    • Created a controller to handle incoming requests related to ToDo items.
    • Implemented methods for creating, retrieving all, retrieving by ID, updating, patching, and deleting ToDo items.
    • Each method handles errors appropriately and returns a consistent response format.
  2. Service (services/todoService.js):

    • Created a service layer to encapsulate the business logic for ToDo items.
    • Implemented validation for ToDo data to ensure that the title is a non-empty string and that the due date, if provided, is a valid date.
    • Methods for creating, retrieving, updating, patching, and deleting ToDo items are defined, with error handling for not found scenarios.
  3. Routes (routes/todoRoutes.js):

    • Defined routes for the ToDo API, mapping HTTP methods to the corresponding controller methods.
    • Routes include endpoints for creating, retrieving all, retrieving by ID, updating, patching, and deleting ToDo items.
  4. App Integration (app.js):

    • Updated the main application file to include the ToDo API routes by importing todoRoutes and using it with the Express app.
    • Ensured that the app can handle JSON requests.

This implementation follows best practices for structuring an API and provides a solid foundation for further enhancements or modifications.

Merge request reports