-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (24 loc) · 825 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
const express = require('express');
const path = require('path');
const logger = require('morgan');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const MongoClient = require('mongodb').MongoClient;
const cors = require('cors');
const app = express();
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cors());
const router = require('./route/route');
dotenv.config();
(async () => {
const client = await MongoClient.connect(process.env.DB, { useNewUrlParser:true });
const db = client.db('Udaan-19');
// const userDb = client.db('Udaan-19-users');
console.log('Connected to database');
app.use('/', router(db))
// app.use('/events', events(db));
// app.use('/users', users(userDb));
})();
module.exports = app;