UNPKG

et

Version:

effortlessness, et al.

38 lines (30 loc) 911 B
// Generated by CoffeeScript 1.4.0 var EtStatic, fs, nstatic; nstatic = require('node-static'); fs = require('fs'); module.exports = EtStatic = (function() { function EtStatic() {} EtStatic.config = function(et, opts) { var key, path, re, servers, _results; if (opts["static"]) { servers = {}; _results = []; for (key in opts["static"]) { path = opts["static"][key].path; if (fs.existsSync(path)) { et.log.debug('stattic assign %s', path); servers[key] = new nstatic.Server(path); re = new RegExp("^/" + key + "/"); _results.push(opts.app.get(re, function(req, res, next) { req.url = req.url.replace(re, ''); return servers[key].serve(req, res, next); })); } else { _results.push(void 0); } } return _results; } }; return EtStatic; })();