Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Region Management Routes #8

Open
nani-samireddy opened this issue Jun 26, 2024 · 0 comments
Open

Implement Region Management Routes #8

nani-samireddy opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels

Comments

@nani-samireddy
Copy link
Member

We need to implement a set of API routes to manage regions in our application. Each region will have the following details:

  • name: The name of the region.
  • description: A brief description of the region.
  • createdBy: The user who created the region.
  • polygon: A list of location points that represent a polygon on the map.

Routes to be Implemented

Route Method Endpoint Input Response
Get All GET /api/region/ None Array of available regions
Get By ID GET /api/region/:id id as path parameter Single region details
Create POST /api/region/ name, description, polygon Message
Update By ID PUT /api/region/:id Fields to be updated Message
Delete By ID DELETE /api/region/:id None Message

Middleware for Authentication

  • All the above requests should only be allowed if a superadmin is logged in.
  • Create a middleware to check if the logged-in user is a superadmin.

Tasks

  1. Define Region Model: Update or create the Region model to include name, description, createdBy, and polygon.

  2. Implement Middleware: Create a middleware function to check if the logged-in user is a superadmin.

  3. Implement Routes:

    • getAll: Fetch and return an array of available regions.
    • getById: Fetch and return details of a single region by its ID.
    • create: Add a new region with the given details.
    • updateById: Update the details of an existing region by its ID.
    • deleteById: Delete a region by its ID.
  4. Add Routes to API Testing Tool: Add the new routes to the Bruno API testing tool for easy testing and verification.

  5. Testing: Write tests for each route to ensure they are working correctly and are properly secured with the middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants