-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (33 loc) · 1.18 KB
/
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
39
40
41
42
43
44
45
var express = require('express'),
app = express(),
port = process.env.PORT || 8080,
server = require('http').createServer(app),
mongoose = require('mongoose'),
passport = require('passport'),
flash = require('connect-flash'),
morgan = require('morgan');
cookieParser= require('cookie-parser'),
bodyParser = require('body-parser'),
session = require('express-session'),
configDB = require('./config/database.js'),
route = require('./app/routes.js');
// Set-up ============================================
mongoose.connect(configDB.url);
require('./config/passport')(passport);
app.use(morgan('dev'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', __dirname + '/public/views');
app.use(session({ secret: process.env.SKOPOS_SESSION_SECRET }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(express.static( __dirname +'/public'));
// Routes ============================================
route(app,passport);
// Run ============================================
app.listen(port,function(){
console.log("Listening port: " + port);
});