waffel
Version:
Static site generation done tasty.
39 lines (32 loc) • 934 B
JavaScript
// Generated by CoffeeScript 1.11.1
var Server, express,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
express = require('express');
module.exports = Server = (function() {
function Server(opts) {
this.stop = bind(this.stop, this);
this.start = bind(this.start, this);
this.options = opts;
this.started = false;
this.app = express();
}
Server.prototype.start = function() {
if (this.started) {
return;
}
this.app.use(express["static"](this.options.path, this.options));
return new Promise((function(_this) {
return function(resolve, reject) {
return _this.app.listen(_this.options.port, function() {
_this.started = true;
return resolve(_this);
});
};
})(this));
};
Server.prototype.stop = function() {
this.app.close();
return this.started = false;
};
return Server;
})();