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

ProviderId routes #51

Open
ArslanKamchybekov opened this issue Oct 27, 2024 · 0 comments
Open

ProviderId routes #51

ArslanKamchybekov opened this issue Oct 27, 2024 · 0 comments
Assignees

Comments

@ArslanKamchybekov
Copy link
Collaborator

Backend Task: Add providerId to Service and Insurance Schemas and Create Endpoint to Fetch All Services and Insurances by providerId

Objective:

Modify the Service and Insurance schemas to include a providerId field, which will link each service and insurance to a specific provider. Implement an endpoint that allows fetching all services and insurances associated with a given providerId.


Steps:

  1. Update Service and Insurance Schemas
    • Add a providerId field in both the Service and Insurance schemas.
    • Set providerId as a required field, make it a simple string or ObjectId field.
  2. Update Service and Insurance Creation Logic
    • Ensure that any function or endpoint responsible for creating a Service or Insurance entry accepts and sets providerId based on the logged-in user (if the provider is determined by authentication) or from the request data.
    • Validate that only users with the provider role can set providerId.
  3. Create a New Endpoint to Fetch Services by providerId
    • Define a new endpoint GET /service/provider/:providerId to retrieve all services associated with a specific providerId.
    • Query the Service model to filter by providerId and return the list of services.
  4. Create a New Endpoint to Fetch Insurances by providerId
    • Define a new endpoint GET /insurance-plan/provider/:providerId to retrieve all insurances associated with a specific providerId.
    • Query the Insurance model to filter by providerId and return the list of insurances.
  5. Add Role-Based Authorization
    • Use middleware to ensure that only users with admin or provider roles can access these endpoints.
    • If using NestJS, apply @Roles('admin', 'provider') to these methods to restrict access.
  6. Testing
    • Test the updated schema to ensure providerId is saved correctly when a new service or insurance is created.
    • Test the new endpoints by querying with valid and invalid providerId values to verify correct functionality and error handling.
    • Test role-based access to confirm only admin and provider roles can access the endpoints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants