UNPKG

thinkable-ducks

Version:

supervisor-controlled image for useful-wind

50 lines (44 loc) 1.15 kB
// Generated by CoffeeScript 2.4.1 (function() { // Web Services // ============ var Zappa, pkg, serialize; Zappa = require('core-zappa'); pkg = require('./package.json'); serialize = require('useful-wind-serialize'); module.exports = function(cfg) { var web; if (cfg.web == null) { return; } if (cfg.versions == null) { cfg.versions = {}; } cfg.versions[pkg.name] = pkg.version; return web = Zappa.run(cfg.web, async function() { var errors; this.use({ morgan: 'combined' }); this.helper({cfg}); this.cfg = cfg; // Generic statistics // ------------------ this.get('/', function() { return this.json({ ok: true, package: pkg.name, uptime: process.uptime(), memory: process.memoryUsage(), versions: this.cfg.versions }); }); // Modules web services // -------------------- errors = (await serialize.modules(cfg.use, this, 'web')); if (errors > 0) { throw new Error(`web had ${errors} errors`); } }); }; }).call(this);