-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (24 loc) · 1.05 KB
/
server.js
File metadata and controls
30 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import "./env.js"; // for loading environment veriable before anywhere in use
import express from "express";
import cookieParser from "cookie-parser";
import doctorRouter from "./src/feature/doctor/doctor.routes.js";
import patientRouter from "./src/feature/patients/patient.routes.js";
import reportRouter from "./src/feature/report/report.routes.js";
import { connectToMongoose } from "./src/config/mongoose.js";
import { jwtAuth } from "./src/middleware/jwt_auth.js";
const app = express();
const port = process.env.port;
app.use(express.urlencoded({extended: true}));
app.use(express.json());
app.use(cookieParser());
app.use('/api/doctors', doctorRouter);
app.use('/api/patients', jwtAuth, patientRouter); // using JWT auth middlewre so that only doctors can register patients and create their report
app.use("/api/reports", jwtAuth, reportRouter);
// rest of all routes will reffer here
app.get('/', (req, res)=>{
res.send('Welcome to Hospital Api')
})
app.listen(port, ()=>{
console.log("server is listning on port", port);
connectToMongoose();
})