all files / middleware/ config.js

100% Statements 10/10
100% Branches 0/0
100% Functions 1/1
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                     
/**
 * Config middleware, binds a clone of app.config to ctx
 **/
'use strict';
 
const $     = require('lodash');
const debug = require('debug')('lark.middlewares.config');
 
debug('loading ...');
 
function middleware (config = {}, app = {}) {
    return (ctx, next) => {
        debug('binding config ...');
        ctx.config = $.cloneDeep(app.config);
        return next();
    }    
}
 
debug('loaded!');
module.exports = middleware;