This commit is contained in:
rgrgogu
2026-05-05 23:18:47 +08:00
parent 5aeb959e92
commit a8f10a25d7
38 changed files with 5992 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
/***********************************************************************************************************************************************************************
* File Name: client.routes.js
* Type of Program: Router
* Description: Protected routes accessible by any authenticated user (client, staff, admin).
*
* Route Map:
* GET /api/client/profile → view own profile
* PUT /api/client/profile → update own profile
* GET /api/client/sessions → view own active sessions
* DELETE /api/client/sessions/:id → revoke own session
*
* Guards: authenticate → requireClient()
*
* Author: rgrgogu
* Date Created: Oct. 6, 2025
***********************************************************************************************************************************************************************/
const express = require('express');
const router = express.Router();
const profileCtrl = require('../../controllers/client/profile.controller');
const { authenticate } = require('../../middleware/auth.middleware');
const { requireClient } = require('../../middleware/rbac.middleware');
const { validate } = require('../../middleware/validate.middleware');
const { updateProfileValidator } = require('../../validators/profile.validator');
// Apply auth + role to all routes in this file
router.use(authenticate, requireClient());
router.get('/profile', profileCtrl.getProfile);
router.put('/profile', ...updateProfileValidator, validate, profileCtrl.updateProfile);
router.get('/sessions', profileCtrl.getSessions);
router.delete('/sessions/:id', profileCtrl.revokeSession);
module.exports = router;