1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 1x 24x 2x 22x 4x 18x 1x 1x 14x 1x 13x 2x 11x 1x | const errors = require('./errors'); exports.middleware = middle => { if (!middle) { throw errors.MissingMiddleware(); } if (!(middle instanceof Function)) { throw errors.InvalidMiddleware({ type: typeof middle }); } if (middle.length === 4) { throw errors.ErrorMiddleware(); } } exports.context = ctx => { if (!ctx) { throw errors.MissingContext(); } if (!ctx.req) { throw errors.MalformedContext({ item: 'req' }); } if (!ctx.res) { throw errors.MalformedContext({ item: 'res' }); } } |