-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (22 loc) · 817 Bytes
/
app.js
File metadata and controls
28 lines (22 loc) · 817 Bytes
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
const express = require('express');
const bodyparser = require('body-parser');
var cors = require('cors');
const router = express.Router();
const UserData = require('./routers/router');
const app = express();
const mongoose = require('mongoose');
let dev_db_url = 'mongodb://Anuj:test123@ds119072.mlab.com:19072/chatjs';
const mongoDB = process.env.MONGODB_URI || dev_db_url;
mongoose.connect(mongoDB, { useNewUrlParser: true });
mongoose.Promise = global.Promise;
const db = mongoose.connection;
db.on('error', console.error.bind(console,'MongoDB Connection Error'));
app.use(cors());
app.use(bodyparser.json());
app.use(bodyparser.urlencoded({extended: false}));
app.use('/UserData', UserData);
let port = 1234;
app.listen(port, () => {
console.log('server running: '+ port);
});
module.exports = router;