All files / server/src modules.js

70% Statements 7/10
0% Branches 0/6
60% Functions 3/5
62.5% Lines 5/8
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 27 28 29 30 31  5x 50x             5x   28x 28x                                    
// Modules - All of the modules that are loaded by default
const modern = require('./modern');
const modernOps = factory => (opts => modern(factory(opts)));
 
// ?TODO: something more solid. Maybe a thin wrapper per-module
// List mostly from http://expressjs.com/en/guide/migrating-4.html
// module.exports = [
//   ctx => modern(require('body-parser').urlencoded(ctx.middle.bodyParser))(ctx)
// ];
module.exports = {
  public: modernOps((path, self) => {
    console.log(path, self);
    throw self;
    return self.express.static(path);
  }),
  bodyParser: modernOps(require('body-parser').urlencoded),
  jsonParser: modernOps(require('body-parser').json),
  dataParser: modernOps(require('express-data-parser')),
 
  compress: modernOps(require('compression')),
  cookieParser: modernOps(require('cookie-parser')),
  session: modernOps(opt => opt && opt.secret ? require('express-session')(opt) : false),
  favicon: modernOps(opt => opt ? require('serve-favicon')(opt) : false),
  responseTime: modernOps(require('response-time')),
  methodOverride: modernOps(require('method-override')),
  // TODO: connectTimeout: require('connect-timeout'),
  // TODO: vhost: require('vhost'),
  // TODO: csurf: require('csurf'),
  // ?TODO: serveIndex: (opt, all) => require('serve-index')(all.public)
};