-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (30 loc) · 859 Bytes
/
server.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
'use strict'
var express = require("express");
var app = express();
var mongoose=require("mongoose");
var passport=require("passport");
var session = require('express-session');
//load environment variables
require('dotenv').load();
require('./app/config/passport')(passport);
var appRoute=require("./app/routes/index");
var apiRoute=require("./app/routes/api");
// set the static files location
app.use(express.static(__dirname + '/public'));
app.use(session({
secret: 'nightLifeApp',
resave: false,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
//connect to mongodb
mongoose.connect(process.env.DB_URL);
mongoose.Promise = global.Promise;
//register api routes first
apiRoute(app);
//register app routes
appRoute(app,passport);
app.listen(process.env.PORT, () => {
console.log('listening');
})