blob: 230a53c196e5ab14645b8ecfda23316316898c61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var specificity = require('route-order')();
var express = require('express');
function OKServer(options) {
if (!(this instanceof OKServer)) return new OKServer(options);
options = options || {};
if (!options.views)
throw new Error('No views provided to OKServer!');
var views = options.views;
var app = this._app = express();
// Add views
Object.keys(views)
.sort(specificity)
.forEach(function(route) {
app.use(route, views[route].middleware());
});
}
OKServer.prototype.listen = function listen(port) {
this._app.listen(port || 1337);
return this;
};
module.exports = OKServer;
|