2015-09-04 01:26:56 -04:00
|
|
|
var compression = require('compression');
|
|
|
|
var express = require('express');
|
2015-09-14 13:36:00 -04:00
|
|
|
var _path = require('path');
|
2015-09-04 01:26:56 -04:00
|
|
|
|
|
|
|
var handler = require('./handler');
|
|
|
|
var log = require('./log');
|
|
|
|
var routes = require('./routes.json');
|
|
|
|
|
|
|
|
// Server setup
|
|
|
|
var app = express();
|
|
|
|
app.disable('x-powered-by');
|
|
|
|
app.use(log());
|
|
|
|
app.use(compression());
|
|
|
|
|
|
|
|
// Bind routes
|
|
|
|
for (var item in routes) {
|
|
|
|
var route = routes[item];
|
2015-09-14 12:16:58 -04:00
|
|
|
if ( route.static ) {
|
2015-09-14 13:17:50 -04:00
|
|
|
app.use( express.static( eval( route.resolve ), route.attributes ) );
|
2015-09-14 12:16:58 -04:00
|
|
|
} else {
|
2015-09-14 13:17:50 -04:00
|
|
|
app.get(route.pattern, handler(route));
|
2015-09-14 12:16:58 -04:00
|
|
|
}
|
2015-09-04 01:26:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Start listening
|
2015-09-16 10:40:03 -04:00
|
|
|
var port = process.env.PORT || 8333;
|
2015-09-04 01:26:56 -04:00
|
|
|
app.listen(port, function () {
|
|
|
|
process.stdout.write('Server listening on port ' + port + '\n');
|
|
|
|
});
|