-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·61 lines (50 loc) · 1.8 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
49
50
51
52
53
54
55
56
57
58
59
60
61
var express = require('express');
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var expressSession = require('express-session');
var passport = require('passport');
var passportConfig = require('./config/passport'); // all passport configuration and provider logic
var index = require('./routes/index');
var invoices = require('./routes/invoices');
var users = require('./routes/users');
var paychecks = require('./routes/paychecks');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'app'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
app.use(logger('dev'));
app.use(express.static(path.join(__dirname, 'app'), {
index: false
}));
app.use(express.static(path.join(__dirname, '/'), {
index: false
}));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(expressSession({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session());
app.use('/', index);
app.use('/api/v1/', invoices);
app.use('/api/v1/', users);
app.use('/api/v1/', paychecks);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 3000
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
var server = app.listen(server_port, server_ip_address, function() {
var host = 'localhost';
var port = server.address().port;
console.log('App listening at http://%s:%s', host, port);
});
module.exports = app;