-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
52 lines (44 loc) · 998 Bytes
/
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
var flatiron = require('flatiron'),
app = flatiron.app,
path = require('path'),
config = path.join(__dirname, 'config.json');
var metalsmith = require('./lib/metalsmith');
var handlebars = require('./lib/handlebars');
var watcher = require('./lib/watcher');
/**
* Application configuration
*/
app.config
.argv()
.file({
file: config
})
.defaults({
plugins: {},
output: path.join(__dirname, 'public'),
port: 8080
});
app.config.set('cwd', __dirname);
/**
* Plugins
*/
app.use(handlebars);
app.use(metalsmith);
app.use(flatiron.plugins.http);
if (app.config.get('watch')) {
app.use(watcher);
}
/***
* Routing
*/
app.router.get('/', function() {
this.res.writeHead(200, {
'Content-Type': 'application/json; charset=utf8'
});
this.res.end(JSON.stringify({ 'ヽ(・_・)ノ': 'what?' }));
});
app.router.path('/jitherb', require('./lib/update'));
// Kickoff
app.start(app.config.get('port'), function() {
app.log.info("Application started on port", app.config.get('port'));
});