@@ -3,23 +3,43 @@ import cors from 'cors';
33import morgan from 'morgan' ;
44
55import authRoutes from './routes/auth.routes.js' ;
6+ import signupRoutes from './routes/signup.js' ;
7+ import adminRoutes from './routes/adminroutes.js' ;
8+
69import doctorRoutes from './routes/doctor.routes.js' ;
7-
10+ import nurseRoutes from './routes/nurse.routes.js' ;
11+
12+ import patientRoutes from './routes/patient.js' ;
13+ import deptRoutes from './routes/dept.js' ;
14+ import appointmentRoutes from './routes/appointment.js' ;
815
916const app = express ( ) ;
1017
18+ // Global middleware
1119app . use ( cors ( ) ) ;
1220app . use ( express . json ( ) ) ;
1321app . use ( morgan ( 'dev' ) ) ;
1422
15- app . get ( '/' , ( req , res ) => res . json ( { ok : true } ) ) ;
23+ app . get ( '/' , ( req , res ) => {
24+ res . json ( { ok : true } ) ;
25+ } ) ;
1626
1727app . use ( '/api/auth' , authRoutes ) ;
18- app . use ( '/api' , doctorRoutes ) ;
28+ app . use ( '/api/signup' , signupRoutes ) ;
29+ app . use ( '/api/admin' , adminRoutes ) ;
30+
31+ app . use ( '/api/users/doctors' , doctorRoutes ) ;
32+ app . use ( '/api/users/nurses' , nurseRoutes ) ;
33+
34+ app . use ( '/api/patients' , patientRoutes ) ;
35+ app . use ( '/api/departments' , deptRoutes ) ;
36+ app . use ( '/api/appointments' , appointmentRoutes ) ;
1937
2038app . use ( ( err , req , res , next ) => {
2139 console . error ( err ) ;
22- res . status ( err . status || 500 ) . json ( { error : err . message || 'Server error' } ) ;
40+ res . status ( err . status || 500 ) . json ( {
41+ error : err . message || 'Server error'
42+ } ) ;
2343} ) ;
2444
25- export default app ;
45+ export default app ;
0 commit comments