stonecircle/express-autoroute-json

View on GitHub
lib/select.js

Summary

Maintainability
A
25 mins
Test Coverage
F
55%
var _ = require('lodash');
 
Function `exports` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
module.exports = function(options) {
return function(req, res, next) {
if (options.find && options.find.select) {
var fields = options.find.select(req);
if (_.isArray(fields)) {
fields = fields.join(' ');
}
_.assign(req, {
autorouteSelect: fields,
});
}
next();
};
};