-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
37 lines (30 loc) · 965 Bytes
/
index.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
var express = require('express');
var app = express();
var swig = require('swig');
var http = require('http');
var url = require('url');
var cons = require('consolidate');
var path = require('path');
var bootstrap = require('./routes');
module.exports = function(options) {
// make sure there's a path
if(!options.root) {
var options = {
root: __dirname
}
}
// set swig as templating engine
app.use('/assets', express.static(options.root + '/assets'));
app.engine('html', cons.swig);
app.set('view engine', 'html');
app.set('views', options.root);
// make routes, add content, etc.
bootstrap(app);
// create server
var server = app.listen(8000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Postach.io theme server running at - http://%s:%s\nUsing directory - %s', host, port, options.root);
});
return server;
}