Initial commit - Horux Despachos NL
This commit is contained in:
32
apps/api/src/routes/cartera.routes.ts
Normal file
32
apps/api/src/routes/cartera.routes.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Router, type IRouter } from 'express';
|
||||
import { authenticate, authorize } from '../middlewares/auth.middleware.js';
|
||||
import { tenantMiddleware } from '../middlewares/tenant.middleware.js';
|
||||
import * as ctrl from '../controllers/cartera.controller.js';
|
||||
|
||||
const router: IRouter = Router();
|
||||
|
||||
router.use(authenticate);
|
||||
router.use(tenantMiddleware);
|
||||
|
||||
// Static routes first
|
||||
router.get('/supervisores', authorize('owner'), ctrl.getSupervisores);
|
||||
|
||||
// Read: owner + supervisor + auxiliar
|
||||
router.get('/', authorize('owner', 'supervisor', 'auxiliar'), ctrl.list);
|
||||
router.get('/:id', authorize('owner', 'supervisor', 'auxiliar'), ctrl.getById);
|
||||
router.get('/:id/subcarteras', authorize('owner', 'supervisor', 'auxiliar'), ctrl.listSubcarteras);
|
||||
router.get('/:id/entidades', authorize('owner', 'supervisor', 'auxiliar'), ctrl.getEntidades);
|
||||
router.get('/:id/auxiliares', authorize('owner', 'supervisor', 'auxiliar'), ctrl.getAuxiliares);
|
||||
router.get('/:supervisorId/auxiliares-disponibles', authorize('owner', 'supervisor'), ctrl.getAuxiliaresDelSupervisor);
|
||||
|
||||
// Write: owner + supervisor (with permission checks in controller)
|
||||
router.post('/', authorize('owner', 'supervisor'), ctrl.create);
|
||||
router.put('/:id', authorize('owner', 'supervisor'), ctrl.update);
|
||||
router.delete('/:id', authorize('owner', 'supervisor'), ctrl.remove);
|
||||
router.post('/:id/subcarteras', authorize('owner', 'supervisor'), ctrl.createSubcartera);
|
||||
router.post('/:id/entidades', authorize('owner', 'supervisor'), ctrl.addEntidad);
|
||||
router.delete('/:id/entidades/:entidadId', authorize('owner', 'supervisor'), ctrl.removeEntidad);
|
||||
router.post('/:id/auxiliares', authorize('owner', 'supervisor'), ctrl.addAuxiliar);
|
||||
router.delete('/:id/auxiliares/:auxiliarUserId', authorize('owner', 'supervisor'), ctrl.removeAuxiliar);
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user