-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (42 loc) · 1.46 KB
/
app.js
File metadata and controls
52 lines (42 loc) · 1.46 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import cors from 'cors';
import dotenv from 'dotenv';
import express from 'express';
import http from 'http';
import mongoose from 'mongoose';
import { Server } from 'socket.io';
import { handlePatients, handleVideoChat } from './controllers/consults.controller.js';
import consultRoutes from './routes/consults.js';
import doctorRoutes from './routes/doctors.js';
import donationRoutes from './routes/donations.js';
import donorsRoutes from './routes/donors.js';
import requestBloodRoutes from './routes/requestBlood.js';
import userRoutes from './routes/users.js';
const app = express();
const server = http.createServer(app);
dotenv.config();
app.use(express.json());
app.use(cors({ origin: true }));
const DATABASE_URL = process.env.DATABASE_URL;
const PORT = process.env.PORT || 5000;
app.use('/user', userRoutes);
app.use('/donors', donorsRoutes);
app.use('/donation', donationRoutes);
app.use('/request-blood', requestBloodRoutes);
app.use('/consult', consultRoutes);
app.use('/doctors', doctorRoutes);
const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
},
});
io.on("connection", (socket) => {
handlePatients(io, socket)
handleVideoChat(io, socket)
})
mongoose.connect(DATABASE_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => server.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
}))
.catch(error => console.log(error.message));
mongoose.set('useFindAndModify', false);