Subject Routes
Overview
The subject.routes.js file defines the HTTP routes for the subject service. It maps the routes to the corresponding controller functions and applies authorization middleware to protect the routes.
Dependencies
express: The web framework for Node.js../subject.controller.js: The controller functions for subjects.../../middleware/guards.js: The authorization middleware.
Routes
POST /: Creates a new subject. Accessible toadminandteacherroles.GET /:id: Retrieves a single subject by its ID. Accessible toadmin,teacher, andstudentroles.GET /: Retrieves a list of all subjects. Accessible toadmin,teacher, andstudentroles.PUT /:id: Updates an existing subject by its ID. Accessible toadminandteacherroles.DELETE /:id: Deletes a subject by its ID. Accessible toadminrole only.
Authorization
The isAuthorized middleware is used to protect the routes. It ensures that only users with the specified roles can access the routes.
Exports
router: The Express router for the subject service.