-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (24 loc) · 890 Bytes
/
app.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
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const appointmentRoutes = require('./src/routes/appointments');
const voiceCallRoutes = require('./src/routes/voicecalls');
dotenv.config();
const app = express();
const port = process.env.PORT || 3000;
mongoose.connect(process.env.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true });
const db = mongoose.connection;
db.once('open', () => {
console.log('Connected to MongoDB');
});
app.get('/', (req, res) => {
res.send("Welcome to Appointment APIs");
})
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/appointments', appointmentRoutes);
app.use('/voicecalls', voiceCallRoutes);
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});