forked from PresidentDwayneCamacho/Corner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (40 loc) · 1.18 KB
/
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
42
43
44
45
46
47
48
/*
server.js
entry point for the program
*/
// include dependencies
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var passport = require('passport');
var logger = require('morgan');
var session = require('express-session');
var app = express();
// connect to database
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/post-rough');
// config passport
require('./config/passport')(passport);
// set html file directory
app.use(express.static(path.join(__dirname, 'public')));
// require backend router (api)
var api = require('./routes/api.js');
// connect dependencies
app.use(logger('dev'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(session({
secret: '23zwk3dDK384idw2SEWI23fwe9WRe',
resave: true,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.use('/',api);
// listen to server
app.set('port',process.env.PORT || 3000);
app.listen(app.get('port'),function(){
console.log('Server started on port ' + app.get('port'));
});