-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
34 lines (27 loc) · 1.28 KB
/
server.js
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
31
32
33
34
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const DB = require('./config/postgres.config');
const app = express();
DB.raw('select 1+1 as result').then(function () {
console.log("Connneted to DB");
});
app.use(bodyParser.json());
app.use(cors());
app.get('/', (req, res) => {
res.json("Server Running");
})
const hospitals = require('./controllers/hospitals');
const doctors = require('./controllers/doctors');
const appointmentBooking = require('./controllers/appointmentBooking');
app.get( '/hospitals', (req, res) => { hospitals.allHospitalDetailsHandler(req, res, DB)});
app.get( '/hospitalPage/:hospitalId', (req, res) => { hospitals.hospitalDetailsByIdHandler(req, res, DB)});
app.get( '/doctors/:hospitalId', (req, res) => { doctors.allDoctorDetailsHandler(req, res, DB)});
app.get( '/doctors/:hospitalId/:doctorId', (req, res) => { doctors.doctorDetailsByIdHandler(req, res, DB)});
app.post( '/booking-appointment/:hospitalId/:doctorId', (req, res) => { appointmentBooking.appointmentHandler(req, res, DB)});
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log("The server is listening on port", PORT);
console.log("The environment is", process.env.NODE_ENV);
console.log(process.env.DATABASE_URL);
});