-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
140 lines (112 loc) · 5.05 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const cors = require('cors');
const path = require('path');
const authRouter = require('./routes/authRoutes');
const patientRouter = require('./routes/patientRoutes');
const doctorRouter = require('./routes/doctorRoutes');
const addressRouter = require('./routes/addressRoutes');
const reportRouter = require('./routes/reportRoutes');
const slotsController = require('./controllers/slotsController');
const notiRouter = require('./routes/notificationRoutes');
const PORT = process.env.PORT || 3000;
const CONN_URI = 'mongodb://orchardmongo.eastus.cloudapp.azure.com:27017/Orchard1';
// mongoose.connect(CONN_URI, {
// auth: {
// user: "mongoUser1",
// password: "User1pwd"
// },
// useNewUrlParser: true,
// useUnifiedTopology: true
// },
// (err) => {
// if (err) {
// console.log(err);
// } else {
// console.log('Connected to db!');
// }
// });
app.use(cors());
app.use(bodyParser.json());
app.use('/api/auth', authRouter);
app.use('/api/patient', patientRouter);
app.use('/api/doctor', doctorRouter);
app.use('/api/address', addressRouter);
app.use('/api/reports', reportRouter);
app.use('/api/notification', notiRouter);
app.use("/images", express.static(path.join("images")));
app.use("/reports", express.static(path.join("reports")));
//app.get('/api/patient/getSlots/:docId/:date', slotsController.getSlots);
app.listen(PORT, () => {
console.log(`Server started running at port ${PORT}`);
})
module.exports = app;
//db.collection1.insert(db.collection1_backup.find({},{_id:0}).toArray());
//const Cities = require('./models/cityModel');
// const userRoutes = require('./routes/userRoutes');
// const loginRouter = require('./routes/login');
// const verifyRouter = require('./routes/verification');
// const forgotPasswordRoute = require('./routes/forgotpassword');
// const patientRoutes = require('./routes/PatientRegistrationRoutes');
// const doctorRoutes = require('./routes/DoctorRegistrationRoutes');
// const patientIdRouter = require('./routes/getPatientById');
// // const patientDetials = require('./routes/PatientDetails');
// const patientLayoutRouter = require('./routes/patientLayoutRoutes');
// const doctorLayoutRouter = require('./routes/doctorLayoutRoutes');
// const AppointmentRouter = require('./routes/Appointments');
// const doctorRouter = require('./routes/doctorRoutes');
// app.use('/patient', patientIdRouter);
// app.use('/doctor', doctorRouter);
// app.post('/patientRegistration', patientRoutes);
// app.use('/api/auth', userRoutes);
// app.use('/doctorRegistration', doctorRoutes);
// app.get('/:email', forgotPasswordRoute);
// app.post('/generateOTP', verifyRouter);
// app.get('/verify/:otp/:email', verifyRouter);
// app.post('/login/:type', loginRouter);
// //app.use('/patient/:id', patientIdRouter);
// app.use('/patientDetail', patientLayoutRouter);
// app.use('/doctorDetail', doctorLayoutRouter);
// const MIME_TYPE_MAP = {
// 'image/png': 'png',
// 'image/jpeg': 'jpg',
// 'image/jpg': 'jpg'
// };
// app.use('/patient/:id', patientIdRouter);
// app.use('/api', AppointmentRouter);
// app.get('/getStates', (req, res) => {
// fetch('https://www.universal-tutorial.com/api/states/india', {
// method: 'GET',
// headers: {
// 'Content-type': 'application/json; charset=UTF-8',
// "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJfZW1haWwiOiJhbmFudHMxMDA4QGdtYWlsLmNvbSIsImFwaV90b2tlbiI6ImtjM0MwMUgwVThBUUdHaGJFTW8zRXZBMWZkNmFhaGp6OEJwSHI2aW00TkRVWG1ZeUQ3TXF2cE9LQ1dQMTEzZE1jZnMifSwiZXhwIjoxNjA3NzAyMDkxfQ.iC-RTEKyb04uKyOz7FF_s4qdm7MNu5-o8LohsV1d0XM",
// "Accept": "application/json"
// },
// }).
// then(response => response.json()).
// then(data => {
// //console.log(data);
// for (let i = 0; i < data.length; i++) {
// console.log(data[i]);
// fetch('https://www.universal-tutorial.com/api/cities/' + data[i].state_name, {
// method: 'GET',
// headers: {
// 'Content-type': 'application/json; charset=UTF-8',
// "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXJfZW1haWwiOiJhbmFudHMxMDA4QGdtYWlsLmNvbSIsImFwaV90b2tlbiI6ImtjM0MwMUgwVThBUUdHaGJFTW8zRXZBMWZkNmFhaGp6OEJwSHI2aW00TkRVWG1ZeUQ3TXF2cE9LQ1dQMTEzZE1jZnMifSwiZXhwIjoxNjA3NzAyMDkxfQ.iC-RTEKyb04uKyOz7FF_s4qdm7MNu5-o8LohsV1d0XM",
// "Accept": "application/json"
// },
// }).
// then(response => response.json()).
// then(async(d) => {
// console.log(d);
// const cities = new Cities();
// cities.state = data[i].state_name;
// cities.cities = d;
// await cities.save();
// res.json({ "msg": "done" });
// })
// }
// });
// });