-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
53 lines (43 loc) · 1.38 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
var express = require('express'),
app = express(),
port = process.env.PORT || 80,
mongoose = require('mongoose'),
passport = require('passport'),
flash = require('connect-flash'),
morgan = require('morgan'),
sanitizer = require('express-sanitized'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
helmet = require('helmet'),
csrf = require('csurf'),
Ddos = require('ddos')
var dbConfig = require('./config/database'),
authConfig = require('./config/auth')
var model = require('./goosedb/models')
mongoose.Promise = global.Promise;
mongoose.connect(dbConfig.url, {
useMongoClient: true
})
app.use(morgan('dev'))
app.use(cookieParser())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(sanitizer())
app.use(helmet())
require('./config/passport')(passport)
app.set('views', __dirname + '/goosedb/templates')
app.use(express.static(__dirname + '/goosedb/static'))
app.set('view engine', 'pug')
app.use(session({ secret: authConfig.secret, resave: false, saveUninitialized: false }))
app.use(passport.initialize())
app.use(passport.session())
app.use(flash())
app.use(csrf())
app.use(function (req, res, next) {
res.locals.csrftoken = req.csrfToken()
next()
})
require('./goosedb/routes')(app, passport)
app.listen(port)
console.log('GooseDB Started on Port: ' + port)