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 23x 2x 21x 4x 17x 1x 13x 2x 11x 11x | const errors = require('./errors'); exports.middleware = middle => { if (!middle) { throw errors.MissingMiddleware(); } if (!(middle instanceof Function)) { throw errors.InvalidMiddleware({ type: typeof middle }); } Iif (middle.length === 4) { throw errors.ErrorMiddleware(); } }; exports.context = ctx => { if (!ctx) { throw errors.MissingContext(); } Iif (!ctx.req) { throw errors.MalformedContext({ item: 'req' }); } Iif (!ctx.res) { throw errors.MalformedContext({ item: 'res' }); } }; |