-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
67 lines (57 loc) · 1.49 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
64
65
66
67
/**
*
* Copyright(c) 2012 meltmedia <[email protected]>
* MIT LICENSE
*
*/
var flatiron = require('flatiron'),
path = require('path'),
routes = require('./lib/plugins/routes'),
handlebarsPlugin = require('./lib/plugins/handlebars'),
connect = require('connect'),
expressUglify = require('express-uglify'),
pkg = require('./package.json'),
app = flatiron.app;
app.config.file({ file: path.join(__dirname, 'config', 'config.json') });
var port = app.config.get('port');
app.use(flatiron.plugins.http, {
/*
* Middleware
*/
before: [
/*
expressUglify.middleware({
src: __dirname + '/public',
logLevel: 'info',
loggerL: app.log
}),
*/
connect.static(__dirname + '/public', {maxAge: 86400000}),
connect.staticCache()
],
after: [
// Add post-response middleware here
],
onError: function(err) {
if(err) {
this.res.writeHead(404, { "Content-Type": "text/html" });
this.res.end(app.render('404'));
}
}
});
app.use(handlebarsPlugin, {
templates: __dirname + "/templates",
defaultLayout: 'layout',
blockHelpers: require('./lib/blockHelpers'),
cacheTemplates: true
});
app.use(routes);
app.start(port,
function(err) {
if(err) throw err;
app.log.info(" name :", pkg.name);
app.log.info(" version :", pkg.version);
app.log.info("started at :", Date());
app.log.info(" on port :", port);
app.log.info(" in mode :", app.env);
});