forked from paullee18/NUSAssist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duplicateIndex.js
40 lines (31 loc) · 1.1 KB
/
duplicateIndex.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
const mongoose = require('mongoose');
const express = require('express');
const router = require('./routes/api/tasks');
const eventsRouter = require('./routes/api/events');
const db = require('./models/task');
const eventsDb = require('./models/event');
const bodyParser = require("body-parser");
const cors = require('cors');
mongoose.connect(
'mongodb+srv://nusassist:<PASSWORD>@nusassist.apx1xlz.mongodb.net/?retryWrites=true&w=majority',
{ useNewUrlParser: true, useUnifiedTopology: true })
.then(() => {
console.log('Connected to database');
})
.catch((err) => {
console.log('Error connecting to DB', err.message);
});
const app = express();
const decodeIDToken = require('./authenticateToken');
app.use(decodeIDToken);
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(cors());
// tasks API routes
app.use('/api/tasks', router);
// events API routes
app.use('/api/events', eventsRouter);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));