-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (36 loc) · 1.05 KB
/
index.js
File metadata and controls
39 lines (36 loc) · 1.05 KB
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
const mongoose = require('mongoose');
const express = require('express');
const vars = require('./globalvars')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const helmet = require('helmet');
const port = vars.port;
const app = express()
// DB Check
mongoose.connect(vars.monoguri)
.then(res => {
console.log('Successfully connected to the database ' + vars.monoguri);
})
.catch(err => {
console.log(err);
console.log('Cannot connect to the database!')
console.log(vars.monoguri)
});
app.use(helmet())
app.use(helmet.xssFilter())
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(cookieParser())
app.use(bodyParser.json());
app.set('views', './app/views');
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use('/api', require('./app/apirouter'))
app.use(require('./app/router'))
app.listen(port, () => {
console.log('listening on port ' + port);
});
process.on('uncaughtException', function (err) {
console.log('Caught exception: ', err);
});