-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
48 lines (38 loc) · 1.35 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
var express = require('express'),
compress = require('compression'),
hbs = require('hbs'),
moment = require('moment'),
router = require(__dirname + '/routes').router,
app = express(),
error = require(__dirname + '/middleware/error');
hbs.registerPartials(__dirname + '/views/partials');
hbs.registerHelper('dateFormat', function(context, block) {
var f = block.hash.format || "MMM DD, YYYY hh:mm:ss A";
return moment(context).format(f);
});
app.set('view engine', 'html');
app.set('views', __dirname + '/views/pages');
app.engine('html', hbs.__express);
app.use(compress({
filter: function(req, res) {
return (/json|text|javascript|css|image\/svg\+xml|application\/x-font-ttf/).test(res.getHeader('Content-Type'));
},
level: 9
}));
if (app.get('env') === 'development'){
app.use(express.static(__dirname + '/public', {maxAge: 86400000}));
}
var route = express.Router();
route.get('/index.html', function(req, res){
res.redirect(301, '/');
});
route.get('/', router.index);
route.get('/projects.html', router.projects);
route.get('/services.html', router.services);
route.get('/downloads.html', router.downloads);
route.get('/about.html', router.about);
route.get('/contact.html', router.contact);
app.use('/', route);
app.use(error.notFound);
app.use(error.serverError);
module.exports = app;