StPfeffer / rusty-roads

A simple route manager application written in Rust
MIT License
0 stars 0 forks source link

Feature Request: Implement Route Scope #81

Closed StPfeffer closed 3 weeks ago

StPfeffer commented 1 month ago

Summary

Implement a comprehensive route management document scope that includes database queries for INSERT, SELECT, and DELETE operations, as well as four API routes for retrieving a route by ID, listing all routes, creating a new route, and deleting a route.

Background

The current route management system lacks a defined scope for handling route documents efficiently. This can lead to inconsistencies and difficulties in managing route-related data. Establishing a clear route document scope will streamline database operations and improve the API's functionality, making it easier for developers to work with route data.

Objectives

  1. Database Operations: Define and implement database queries for inserting, selecting, and deleting route documents.
  2. API Routes: Develop four API routes for managing route documents: get by ID, list all, create, and delete.

Requirements

Database Operations

  1. INSERT Query:

    • Insert new route records into the database.
    • Ensure data validation and integrity constraints are enforced.
  2. SELECT Query:

    • Retrieve route records based on specified criteria.
    • Support querying by route ID and other relevant attributes.
  3. DELETE Query:

    • Remove route records from the database.
    • Ensure proper handling of dependencies and referential integrity.

API Routes

  1. Get Route by ID

    • Endpoint: GET /api/v1/routes/{id}
    • Description: Retrieve details of a specific route by its ID.
    • Response: JSON object containing route details or an error message if the route is not found.
  2. List All Routes

    • Endpoint: GET /api/v1/routes
    • Description: Retrieve a list of all routes.
    • Response: JSON array of route objects.
  3. Create Route

    • Endpoint: POST /api/v1/routes
    • Description: Create a new route record.
    • Request Body: JSON object containing route details.
    • Response: JSON object of the created route or an error message if the creation fails.
  4. Delete Route

    • Endpoint: DELETE /api/v1/routes/{id}
    • Description: Delete a specific route by its ID.
    • Response: Success message or an error message if the deletion fails.

Implementation Plan

  1. Database Schema Design: Review and update the database schema to support route document operations, ensuring all necessary fields and constraints are included.
  2. Query Development: Implement the INSERT, SELECT, and DELETE queries with proper validation and error handling.
  3. API Development: Develop the four API routes, ensuring they handle requests and responses correctly and integrate seamlessly with the database queries.
  4. Documentation: Update the API documentation to include detailed information about the new route document scope, including endpoint descriptions, request/response formats, and examples.
  5. Testing: Perform thorough testing of the database operations and API routes to ensure they work as expected and handle edge cases gracefully.