forked from metalsmith/metalsmith.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
50 lines (39 loc) · 739 Bytes
/
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
var build = require('./build');
var express = require('express');
var port = process.env.PORT || 3000;
/**
* App.
*/
var app = express();
/**
* Development.
*/
app.configure('development', function(){
app.use(express.logger('dev'));
app.use(builder);
});
/**
* Static.
*/
app.use(express.static(__dirname + '/build'));
/**
* Listen.
*/
app.listen(port, function(){
console.log('Server running at http://localhost:' + port + '');
});
/**
* Builder middleware.
*
* @param {Request} req
* @param {Response} res
* @param {Function} next
*/
function builder(req, res, next){
if ('/' != req.path) return next();
build(function(err){
if (err) return next(err);
console.log('Built');
next();
});
}