-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (50 loc) · 1.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var server = require('light-http-server');
var path = require('path');
global.config = require('./resources/config');
global.functions = require('./resources/functions');
/** Initialize TypingDnaClient. The client will make the API requests. */
var TypingDnaClient = require('typingdnaclient');
global.typingDnaClient = new TypingDnaClient(
global.config.typingDNA.apiKey,
global.config.typingDNA.apiSecret,
global.config.typingDNA.apiServer);
/**
* View engine setup
*/
server.set('views', './views');
server.set('view engine', 'pug');
server.set('static', path.join(__dirname,'public'));
server.set('session', {
lifetime:604800,
secret:config.sessionSecret
});
/**
* Ensure that the page is not cached
*/
server.use(function(req, res, next) {
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');
next();
});
/**
* Get request fields from url and body
*/
server.use(function(req, res, next) {
functions.getRequestFields(req,{},function(){
next();
})
});
/**
* Load the main routes
*/
require('./routes/demo')(server);
/**
* Catch 404 and forward to error handler
*/
server.use(function(req, res) {
res.status(404);
res.send('Page not found')
});
module.exports = server;