UNPKG

et

Version:

effortlessness, et al.

56 lines (47 loc) 1.23 kB
// Generated by CoffeeScript 1.4.0 var EtModel; EtModel = (function() { function EtModel() {} EtModel.loadModel = function(opts, plural, defn) { this.models[plural] = defn; if (defn.config instanceof Function) { defn.config(opts, plural); } if (defn.get instanceof Function) { if (defn.get.length !== 2) { console.error("UNDEFINED for " + plural + ".get(req, res)"); return; } return this.routes.get[plural] = { route: "/" + plural + "/:id", callback: defn.get }; } }; EtModel.loadModels = function(opts, models) { var defn, plural, _results; _results = []; for (plural in models) { defn = models[plural]; _results.push(this.loadModel(opts, plural, defn)); } return _results; }; EtModel.config = function(et, opts) { var _base; if (opts == null) { opts = {}; } this.models || (this.models = {}); this.routes || (this.routes = {}); (_base = this.routes).get || (_base.get = {}); if (opts.models) { this.loadModels(opts, opts.models); } return function(req, res, next) { return next(); }; }; return EtModel; })(); module.exports = EtModel;