-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (23 loc) · 949 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
34
35
36
37
38
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
const dotenv = require("dotenv")
dotenv.config()
app.use('*', cors());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}));
//import routes
const otm_route = require("./routes/otm");
const { debug } = require('dotenv/lib/env-options');
app.use('/otm', otm_route);
//connect to db
const _database = "mongodb://" + process.env.MMMUSER + ':' + process.env.PASSWORD + '@'+ process.env.IP +":27017/OneTimeMessage?authSource=admin";
mongoose.connect(_database, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => console.log('Connected to Mongo`DB ...'))
.catch(err => console.error('Could not connect to MongoDB:', err));
app.listen(4000);