All files / modernize index.js

100% Statements 9/9
100% Branches 2/2
100% Functions 4/4
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161x     1x 20x         13x 10x 6x 6x      
const validate = require('./validate');
 
// Pass it an old middleware and return a context => promise kind of
module.exports = middle => {
  validate.middleware(middle);
 
  // if (middleware.length === 4) => then WTF?
 
  // Returns a modern middleware type
  return ctx => new Promise((resolve, reject) => {
    validate.context(ctx);
    const next = err => err ? reject(err) : resolve(ctx);
    middle(ctx.req, ctx.res, next);
  });
}