This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
62 lines (50 loc) · 1.89 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
62
// .env loading ============================================
// development purposes only
if(!process.env.hasOwnProperty("REQUIRE_DOT_ENV") || process.env.REQUIRE_DOT_ENV === "true") require('dotenv').config();
// modules =================================================
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var session = require('express-session');
var methodOverride = require('method-override');
var crypto = require('crypto');
// configuration ===========================================
// set our port
app.set('port', (process.env.PORT_2018 || 7000));
// get all data/stuff of the body (POST) parameters
// parse application/json
app.use(bodyParser.json());
// parse application/vnd.api+json as json
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse cookies
var key = process.env.COOKIE_SECRET_2018 || "@\\Ks\\\"+#s}XA$c5@6PqJK-,7S+X5t^v^X&$[";
// refer to the express-session docs: https://github.com/expressjs/session
app.use(session(
{
path: '/',
name: 'ruhacks-2018',
secret: key,
httpOnly: true,
secure: false,
maxAge: null,
resave: false,
saveUninitialized: false,
cookie: {
path: '/'
}
}
));
// override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT
app.use(methodOverride('X-HTTP-Method-Override'));
// set the static files location /public/img will be /img for users
app.use(express.static(__dirname + '/public'));
// routes ==================================================
require('./app/routes')(app); // configure our routes
// start app ===============================================
app.listen(app.get('port'), function() {
console.log('2018: Node app is running on port', app.get('port'));
});
// expose app
exports = module.exports = app;