@@ -4,11 +4,12 @@ import healthRoutes from './routes/health';
44import { patientAuthProxy } from './proxy/patient.auth.proxy' ;
55import { patientDataProxy } from './proxy/patient.data.proxy' ;
66import { staffAuthProxy } from './proxy/staff.auth.proxy' ;
7- import staffDataRouter from './routes/staff.data.router' ;
7+ // import staffDataRouter from './routes/staff.data.router';
88import { authenticate } from './middlewares/auth.middleware' ;
99import { requirePatientSelf } from './middlewares/patient.guard' ;
1010import { createProxyMiddleware } from 'http-proxy-middleware' ;
11-
11+ import { requirePermission } from './middlewares/rbac.middleware' ;
12+ import { staffDataProxy } from './proxy/staff.data.proxy' ;
1213const app = express ( ) ;
1314
1415app . use (
@@ -39,8 +40,29 @@ app.use(
3940) ;
4041// STAFF auth
4142app . use ( '/staff/public' , staffAuthProxy ) ;
42- app . use ( '/staff' , authenticate , staffDataRouter ) ;
4343
44+ app . use ( '/staff' , authenticate , staffDataProxy ) ;
45+
46+ app . use ( '/admin' , authenticate , staffDataProxy ) ;
47+
48+ app . use (
49+ '/admissions' ,
50+ authenticate ,
51+ ( req : any , _res , next ) => {
52+ if ( req . user ?. sub ) req . headers [ 'x-user-id' ] = String ( req . user . sub ) ;
53+
54+ if ( req . user ?. role ) req . headers [ 'x-user-role' ] = String ( req . user . role ) ;
55+
56+ if ( req . user ?. type ) req . headers [ 'x-user-type' ] = String ( req . user . type ) ;
57+
58+ next ( ) ;
59+ } ,
60+ createProxyMiddleware ( {
61+ target : process . env . PATIENT_SERVICE_URL ,
62+ changeOrigin : true ,
63+ pathRewrite : ( path ) => `/admissions${ path } ` ,
64+ } )
65+ ) ;
4466//Appointment routes (accessible by PATIENT + STAFF + ADMIN)
4567
4668app . use (
0 commit comments