Apply ES6 guidelines to external modules

This commit is contained in:
Aurélien Georget 2016-07-11 13:03:35 +02:00
parent 086e05c31f
commit 8cbe59a955
28 changed files with 113 additions and 113 deletions

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* Expose main routes of the generated API
*/
module.exports = function dataForRoutesJSON(scope) {
module.exports = scope => {
const newRoutes = {
routes: {}
};

View File

@ -20,7 +20,7 @@ const pluralize = require('pluralize');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0]) {
return cb.invalid('Usage: `$ strapi generate:api apiName`');
}

View File

@ -22,15 +22,15 @@ module.exports = {
* @return {Promise}
*/
fetchAll: function (params) {
return new Promise(function(resolve, reject) {
fetchAll: params => {
return new Promise((resolve, reject) => {
<%= globalID %>.forge(params).query(params).fetchAll({
withRelated: _.keys(_.groupBy(_.reject(strapi.models.<%= id %>.associations, {autoPopulate: false}), 'alias'))
})
.then(function(<%= idPluralized %>) {
.then(<%= idPluralized %> => {
resolve(<%= idPluralized %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
});
@ -42,15 +42,15 @@ module.exports = {
* @return {Promise}
*/
fetch: function (params) {
return new Promise(function(resolve, reject) {
fetch: params => {
return new Promise((resolve, reject) => {
<%= globalID %>.forge(_.pick(params, 'id')).fetch({
withRelated: _.keys(_.groupBy(_.reject(strapi.models.<%= id %>.associations, {autoPopulate: false}), 'alias'))
})
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
});
@ -62,13 +62,13 @@ module.exports = {
* @return {Promise}
*/
add: function (values) {
return new Promise(function(resolve, reject) {
add: values => {
return new Promise((resolve, reject) => {
<%= globalID %>.forge(values).save()
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
});
@ -80,13 +80,13 @@ module.exports = {
* @return {Promise}
*/
edit: function (params, values) {
return new Promise(function(resolve, reject) {
edit: (params, values) => {
return new Promise((resolve, reject) => {
<%= globalID %>.forge(params).save(values, {path: true})
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
});
@ -98,13 +98,13 @@ module.exports = {
* @return {Promise}
*/
remove: function (params) {
return new Promise(function(resolve, reject) {
remove: params => {
return new Promise((resolve, reject) => {
<%= globalID %>.forge(params).destroy()
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
});
@ -116,8 +116,8 @@ module.exports = {
* @return {Object}
*/
addRelation: function (params, values) {
return new Promise(function(resolve, reject) {
addRelation: (params, values) => {
return new Promise((resolve, reject) => {
const relation = _.find(strapi.models.<%= id %>.associations, {alias: params.relation});
if (!_.isEmpty(relation) && _.isArray(values)) {
@ -135,19 +135,19 @@ module.exports = {
});
Promise.all(arrayOfPromises)
.then(function () {
.then(() => {
resolve();
})
.catch(function (err) {
.catch(err => {
reject(err);
});
break;
case 'manyToMany':
<%= globalID %>.forge(_.omit(params, 'relation'))[params.relation]().attach(values)
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
break;
@ -166,8 +166,8 @@ module.exports = {
* @return {Object}
*/
editRelation: function (params, values) {
return new Promise(function(resolve, reject) {
editRelation: (params, values) => {
return new Promise((resolve, reject) => {
const relation = _.find(strapi.models.<%= id %>.associations, {alias: params.relation});
if (!_.isEmpty(relation) && _.isArray(values)) {
@ -178,10 +178,10 @@ module.exports = {
const data = _.set({}, params.relation, _.first(values) || null);
<%= globalID %>.forge(_.omit(params, 'relation')).save(data, {path: true})
.then(function(user) {
.then(<%= id %> => {
resolve();
})
.catch(function(err) {
.catch(err => {
reject(err);
});
break;
@ -191,12 +191,12 @@ module.exports = {
<%= globalID %>.forge(_.omit(params, 'relation')).fetch({
withRelated: _.get(params, 'relation')
})
.then(function(<%= id %>) {
.then(<%= id %> => {
const data = <%= id %>.toJSON() || {};
const currentValues = _.keys(_.groupBy(_.get(data, _.get(params, 'relation')), PK));
const valuesToRemove = _.difference(currentValues, values);
const arrayOfPromises = _.map(valuesToRemove, function (value) {
const arrayOfPromises = _.map(valuesToRemove, value => {
const params = {};
_.set(params, PK, value);
@ -207,8 +207,8 @@ module.exports = {
return Promise.all(arrayOfPromises);
})
.then(function() {
const arrayOfPromises = _.map(values, function (value) {
.then(() => {
const arrayOfPromises = _.map(values, value => {
const params = {};
_.set(params, PK, value);
@ -219,10 +219,10 @@ module.exports = {
return Promise.all(arrayOfPromises);
})
.then(function () {
.then(() => {
resolve();
})
.catch(function (err) {
.catch(err => {
reject(err);
});
break;
@ -230,12 +230,12 @@ module.exports = {
<%= globalID %>.forge(_.omit(params, 'relation')).fetch({
withRelated: _.get(params, 'relation')
})
.then(function(<%= id %>) {
.then(<%= id %> => {
const data = <%= id %>.toJSON() || {};
const PK = utils.getPK('<%= globalID %>', <%= globalID %>, strapi.models);
const currentValues = _.keys(_.groupBy(_.get(data, _.get(params, 'relation')), PK));
const valuesToAdd = _.difference(_.map(values, function(o) {
const valuesToAdd = _.difference(_.map(values, o => {
return o.toString();
}), currentValues);
@ -244,21 +244,21 @@ module.exports = {
return <%= id %>;
})
})
.then(function(<%= id %>) {
.then(<%= id %> => {
const data = <%= id %>.toJSON() || {};
const PK = utils.getPK('<%= globalID %>', <%= globalID %>, strapi.models);
const currentValues = _.keys(_.groupBy(_.get(data, _.get(params, 'relation')), PK));
const valuesToDrop = _.difference(currentValues, _.map(values, function(o) {
const valuesToDrop = _.difference(currentValues, _.map(values, o => {
return o.toString();
}));
return <%= globalID %>.forge(_.omit(params, 'relation'))[params.relation]().detach(valuesToDrop);
})
.then(function() {
.then(() => {
resolve();
})
.catch(function(err) {
.catch(err => {
reject(err);
});
break;
@ -277,8 +277,8 @@ module.exports = {
* @return {Promise}
*/
removeRelation: function (params, values) {
return new Promise(function(resolve, reject) {
removeRelation: (params, values) => {
return new Promise((resolve, reject) => {
const relation = _.find(strapi.models.<%= id %>.associations, {alias: params.relation});
if (!_.isEmpty(relation) && _.isArray(values)) {
@ -286,7 +286,7 @@ module.exports = {
case 'manyToOne':
const PK = utils.getPK(_.get(relation, relation.type), undefined, strapi.models);
const arrayOfPromises = _.map(values, function (value) {
const arrayOfPromises = _.map(values, value => {
const parameters = {};
_.set(parameters, PK, value);
@ -296,19 +296,19 @@ module.exports = {
});
Promise.all(arrayOfPromises)
.then(function () {
.then(() => {
resolve();
})
.catch(function (err) {
.catch(err => {
reject(err);
});
break;
case 'manyToMany':
<%= globalID %>.forge(_.omit(params, 'relation'))[params.relation]().detach(values)
.then(function(<%= id %>) {
.then(<%= id %> => {
resolve(<%= id %>);
})
.catch(function(err) {
.catch(err => {
reject(err);
});
break;

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0]) {
return cb.invalid('Usage: `$ strapi generate:controller controllerName apiName`');
}

View File

@ -23,13 +23,13 @@ const dictionary = require('strapi-utils/lib/dictionary');
* @param {Function} cb
*/
module.exports = function afterGenerate(scope, cb) {
module.exports = (scope, cb) => {
async.parallel({
migrationFile: function (cb) {
migrationFile: cb => {
const migrationFile = path.resolve(scope.rootPath, 'data', 'migrations', scope.connection, scope.filename);
// Read the migration file.
fs.readFile(migrationFile, 'utf8', function (err, data) {
fs.readFile(migrationFile, 'utf8', (err, data) => {
if (err) {
return cb.invalid(err);
}
@ -49,21 +49,21 @@ module.exports = function afterGenerate(scope, cb) {
});
});
},
settings: function (cb) {
settings: cb => {
dictionary.aggregate({
dirname: path.resolve(scope.rootPath, 'api'),
filter: /(.+)\.settings.json$/,
depth: 4
}, cb);
},
functions: function (cb) {
functions: cb => {
dictionary.aggregate({
dirname: path.resolve(scope.rootPath, 'api'),
filter: /(.+)\.js$/,
depth: 4
}, cb);
}
}, function (err, data) {
}, (err, data) => {
if (err) {
return cb.invalid(err);
}
@ -72,11 +72,11 @@ module.exports = function afterGenerate(scope, cb) {
const models = _.get(_.merge(data.settings, data.functions), 'models');
if (!_.isUndefined(models)) {
_.mapValues(models, function (model) {
_.mapValues(models, model => {
return _.omitBy(model, _.isFunction);
});
const modelsKeyLowercased = _.mapKeys(models, function (model, key) {
const modelsKeyLowercased = _.mapKeys(models, (model, key) => {
return key.toLowerCase();
});
@ -88,7 +88,7 @@ module.exports = function afterGenerate(scope, cb) {
keep_function_indentation: true,
space_before_conditional: true,
end_with_newline: true
}), 'utf8', function (err) {
}), 'utf8', err => {
if (err) {
return cb.invalid(err);
} else {

View File

@ -23,7 +23,7 @@ const builder = require('./builder');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0] || !scope.args[1]) {
return cb.invalid('Usage: `$ strapi migrate:make <connection_name> <migration_name>`');
}
@ -86,7 +86,7 @@ module.exports = function (scope, cb) {
})();
// Register every model.
const migrations = glob.sync(path.resolve(scope.rootPath, 'api', '**', 'models', '*.json')).map((filepath) => {
const migrations = glob.sync(path.resolve(scope.rootPath, 'api', '**', 'models', '*.json')).map(filepath => {
try {
const file = JSON.parse(fs.readFileSync(path.resolve(filepath)));
@ -103,18 +103,18 @@ module.exports = function (scope, cb) {
}
// First, we need to know if the table already exists.
scope.db.schema.hasTable(modelName).then(function (exists) {
scope.db.schema.hasTable(modelName).then(exists => {
// If the table doesn't exist.
if (!exists) {
// Builder: add needed options specified in the model
// for each option.
_.forEach(scope.models[modelName].options, function (value, option) {
_.forEach(scope.models[modelName].options, (value, option) => {
builder.options(scope.models, modelName, value, option);
});
// Builder: create template for each attribute-- either with a column type
// or with a relationship.
_.forEach(scope.models[modelName].attributes, function (details, attribute) {
_.forEach(scope.models[modelName].attributes, (details, attribute) => {
if (details.type && _.isString(details.type)) {
builder.types(scope.models, modelName, details, attribute);
} else if (_.isString(details.collection) || _.isString(details.model)) {
@ -135,7 +135,7 @@ module.exports = function (scope, cb) {
const attributesAddedOrUpdated = _.difference(_.keys(scope.models[modelName].attributes), attributesRemoved);
// Parse every attribute which has been removed.
_.forEach(attributesRemoved, function (attribute) {
_.forEach(attributesRemoved, attribute => {
const details = scope.models[modelName].oldAttributes[attribute];
details.isRemoved = true;
@ -152,7 +152,7 @@ module.exports = function (scope, cb) {
});
// Parse every attribute which has been added or updated.
_.forEach(attributesAddedOrUpdated, function (attribute) {
_.forEach(attributesAddedOrUpdated, attribute => {
const details = scope.models[modelName].attributes[attribute];
// If it's a new attribute.
@ -171,7 +171,7 @@ module.exports = function (scope, cb) {
// If it's an existing attribute.
// Try to identify attribute updates
const toDrop = (function () {
const toDrop = (() => {
if (details.hasOwnProperty('collection') && details.hasOwnProperty('via') &&
(_.get(scope.models[modelName].oldAttributes[attribute], 'collection') !== details.collection || _.get(scope.models[modelName].oldAttributes[attribute], 'via') !== details.via)) {
return true;
@ -226,7 +226,7 @@ module.exports = function (scope, cb) {
}
});
return new Promise((resolve) => {
return new Promise(resolve => {
asyncFunction(filepath, resolve);
});
}

View File

@ -16,7 +16,7 @@ const _ = require('lodash');
* and drop the table to reverse the migration.
*/
module.exports = function (models, modelName) {
module.exports = (models, modelName) => {
// Template: create the table for the `up` export if it doesn't exist.
// This adds a `up` logic for the current model.

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* Add options to a table
*/
module.exports = function (models, modelName, value, option) {
module.exports = (models, modelName, value, option) => {
// Template: add a specific option.
// This is only called when we create a new table.

View File

@ -23,7 +23,7 @@ const selectTable = require('./selectTable');
* Relationship templates
*/
module.exports = function (rootModels, modelName, details, attribute, toDrop, onlyDrop, history) {
module.exports = (rootModels, modelName, details, attribute, toDrop, onlyDrop, history) => {
let tplRelationUp;
let tplRelationDown;
let infos = {};
@ -198,7 +198,7 @@ module.exports = function (rootModels, modelName, details, attribute, toDrop, on
const relationship = models[details.collection].attributes[details.via];
// Construct relation table name.
const relationTable = _.map(_.sortBy([relationship, details], 'collection'), function (table) {
const relationTable = _.map(_.sortBy([relationship, details], 'collection'), table => {
return _.snakeCase(pluralize.plural(table.collection) + ' ' + pluralize.plural(table.via));
}).join('__');

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* Select table
*/
module.exports = function (models, modelName) {
module.exports = (models, modelName) => {
if (!models[modelName].hasOwnProperty('up')) {
models[modelName].up = {
@ -28,7 +28,7 @@ module.exports = function (models, modelName) {
let emptyArrayForDrop = [];
let emptyArrayForOthers = [];
_.forEach(models[modelName].newAttributes, function (attribute, key) {
_.forEach(models[modelName].newAttributes, (attribute, key) => {
if (!_.isEmpty(_.get(models[modelName].attributes, key + '.create.drop'))) {
emptyArrayForDrop.push(true);
}
@ -71,7 +71,7 @@ module.exports = function (models, modelName) {
emptyArrayForDrop = [];
emptyArrayForOthers = [];
_.forEach(models[modelName].newAttributes, function (attribute, key) {
_.forEach(models[modelName].newAttributes, (attribute, key) => {
if (!_.isEmpty(_.get(models[modelName].attributes, key + '.delete.drop'))) {
emptyArrayForDrop.push(true);
}

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* Template types
*/
module.exports = function (models, modelName, details, attribute, toDrop, onlyDrop) {
module.exports = (models, modelName, details, attribute, toDrop, onlyDrop) => {
// Template: create a new column thanks to the attribute's type.
// Firt, make sure we know the attribute type. If not, just do it

View File

@ -19,7 +19,7 @@ const _ = require('lodash');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0]) {
return cb.invalid('Usage: `$ strapi generate:model modelName apiName`');
}

View File

@ -8,6 +8,6 @@
* run jobs, or perform some special logic.
*/
module.exports.bootstrap = function (cb) {
module.exports.bootstrap = cb => {
cb();
};

View File

@ -9,7 +9,7 @@
process.chdir(__dirname);
(function () {
(() => {
const strapi = require('strapi');
strapi.start();
})();

View File

@ -16,7 +16,7 @@ const _ = require('lodash');
* with basic info, dependencies, etc.
*/
module.exports = function dataForPackageJSON(scope) {
module.exports = scope => {
const cliPkg = scope.strapiPackageJSON || {};
// To determine the Strapi dependency to inject

View File

@ -20,7 +20,7 @@ const logger = require('strapi-utils').logger;
* @param {Function} cb
*/
module.exports = function afterGenerate(scope, cb) {
module.exports = (scope, cb) => {
process.chdir(scope.rootPath);
// Copy the default files.

View File

@ -22,7 +22,7 @@ const logger = require('strapi-utils').logger;
* @param {Function} cb
*/
module.exports = function before(scope, cb) {
module.exports = (scope, cb) => {
let defaultName = scope.name;
if (defaultName === '.' || !defaultName) {
defaultName = path.basename(process.cwd());

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0]) {
return cb.invalid('Usage: `$ strapi generate:policy policyName apiName`');
}

View File

@ -15,7 +15,7 @@ const _ = require('lodash');
* @param {Function} cb
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
if (!scope.rootPath || !scope.args[0]) {
return cb.invalid('Usage: `$ strapi generate:service serviceName apiName`');
}

View File

@ -51,7 +51,7 @@ function generate(generator, scope, cb) {
sb.log.verbose('Generating ' + util.inspect(generator) + ' at `' + scope.rootPath + '`...');
// Process all of the generator's targets concurrently.
async.each(Object.keys(generator.targets), function (keyPath, asyncEachCb) {
async.each(Object.keys(generator.targets), (keyPath, asyncEachCb) => {
const asyncEachSb = reportback.extend(asyncEachCb);
// Create a new scope object for this target,
@ -74,7 +74,7 @@ function generate(generator, scope, cb) {
const params = [];
pathRegexp(keyPath, params);
let err;
const parsedKeyPath = _.reduce(params, function (memoKeyPath, param) {
const parsedKeyPath = _.reduce(params, (memoKeyPath, param) => {
if (err) {
return false;
}
@ -115,7 +115,7 @@ function generate(generator, scope, cb) {
// If `target` is an array, run each item.
if (_.isArray(target)) {
async.eachSeries(target, function (targetItem, asyncEachSeriesCb) {
async.eachSeries(target, (targetItem, asyncEachSeriesCb) => {
generateTarget({
target: targetItem,
parent: generator,

View File

@ -22,13 +22,13 @@ const logger = require('strapi-utils').logger;
* @return {[Type]}
*/
module.exports = function (scope, cb) {
module.exports = (scope, cb) => {
cb = cb || {};
cb = reportback.extend(cb, {
error: cb.error,
success: function () {},
notStrapiApp: function () {},
alreadyExists: function () {
success: () => {},
notStrapiApp: () => {},
alreadyExists: () => {
return cb.error();
}
});

View File

@ -19,7 +19,7 @@
* @api private
*/
exports.pathRegexp = function (path, keys, sensitive, strict) {
exports.pathRegexp = (path, keys, sensitive, strict) => {
if (toString.call(path) === '[object RegExp]') {
return path;
}

View File

@ -25,7 +25,7 @@ const CLIENTS = [
* Knex hook
*/
module.exports = function (strapi) {
module.exports = strapi => {
const hook = {
/**
@ -53,11 +53,11 @@ module.exports = function (strapi) {
* Initialize the hook
*/
initialize: function (cb) {
initialize: cb => {
strapi.connections = {};
// For each connection in the config register a new Knex connection.
_.forEach(strapi.config.connections, function (connection, name) {
_.forEach(strapi.config.connections, (connection, name) => {
// Make sure we use the client even if the typo is not the exact one.
switch (connection.client) {

View File

@ -13,7 +13,7 @@ const program = require('commander');
*/
// Allow us to display `help()`, but omit the wildcard (`*`) command.
program.Command.prototype.usageMinusWildcard = program.usageMinusWildcard = function () {
program.Command.prototype.usageMinusWildcard = program.usageMinusWildcard = () => {
program.commands = _.reject(program.commands, {
_name: '*'
});
@ -21,7 +21,7 @@ program.Command.prototype.usageMinusWildcard = program.usageMinusWildcard = func
};
// Force commander to display version information.
program.Command.prototype.versionInformation = program.versionInformation = function () {
program.Command.prototype.versionInformation = program.versionInformation = () => {
program.emit('version');
};

View File

@ -66,7 +66,7 @@ function dictionary(options, cb) {
let dictionary = {};
// Iterate through each module in the set.
_.forEach(files, function (module, filename) {
_.forEach(files, (module, filename) => {
// Build the result object by merging all of the target modules
// NOTE: Each module must export an object in order for this to work
@ -139,7 +139,7 @@ function dictionary(options, cb) {
* @param {Function} cb
*/
module.exports.required = function (options, cb) {
module.exports.required = (options, cb) => {
return dictionary(options, cb);
};
@ -151,7 +151,7 @@ module.exports.required = function (options, cb) {
* @param {Function} cb
*/
module.exports.optional = function (options, cb) {
module.exports.optional = (options, cb) => {
options.optional = true;
return dictionary(options, cb);
};
@ -164,7 +164,7 @@ module.exports.optional = function (options, cb) {
* @param {Function} cb
*/
module.exports.exists = function (options, cb) {
module.exports.exists = (options, cb) => {
options.optional = true;
options.dontLoad = false;
return dictionary(options, cb);
@ -178,7 +178,7 @@ module.exports.exists = function (options, cb) {
* @param {Function} cb
*/
module.exports.aggregate = function (options, cb) {
module.exports.aggregate = (options, cb) => {
options.aggregate = true;
options.optional = true;
return dictionary(options, cb);

View File

@ -19,7 +19,7 @@ const _ = require('lodash');
* @api private
*/
exports.parseJSONFile = function (path, cb) {
exports.parseJSONFile = (path, cb) => {
if (!cb) {
throw new Error('Callback required!');
}
@ -36,7 +36,7 @@ exports.parseJSONFile = function (path, cb) {
return andThen(jsonString);
}
fs.readFile(path, 'utf-8', function (err, file) {
fs.readFile(path, 'utf-8', (err, file) => {
if (err) {
return cb(err);
}
@ -81,7 +81,7 @@ exports.parseJSONFile = function (path, cb) {
* @api private
*/
exports.parseJSONFileSync = function (path) {
exports.parseJSONFileSync = path => {
return exports.parseJSONFile(path, 'sync');
};
@ -94,11 +94,11 @@ exports.parseJSONFileSync = function (path) {
* @api private
*/
exports.getPackage = function (path, cb) {
exports.getPackage = (path, cb) => {
path = _.trimEnd(path, '/');
path += '/package.json';
exports.parseJSONFile(path, function (err, json) {
exports.parseJSONFile(path, (err, json) => {
if (err) {
return cb(err);
}
@ -122,7 +122,7 @@ exports.getPackage = function (path, cb) {
* @api private
*/
exports.getPackageSync = function (path) {
exports.getPackageSync = path => {
path = _.trimEnd(path, '/');
path += '/package.json';

View File

@ -18,7 +18,7 @@ const logger = require('./winston');
* Check if connection is valid
*/
module.exports = function (scope) {
module.exports = scope => {
// First, make sure the application we have access to
// the migration generator.
@ -58,7 +58,7 @@ module.exports = function (scope) {
}
// Make sure the needed client is installed.
_.forEach(scope.connections, function (config) {
_.forEach(scope.connections, config => {
try {
scope.db = require(path.resolve(scope.rootPath, 'node_modules', 'knex'))(scope.dbConfig);
} catch (err) {

View File

@ -13,7 +13,7 @@ const _ = require('lodash');
* @api private
*/
exports.detectRoute = function (endpoint) {
exports.detectRoute = endpoint => {
const verbExpr = /^(all|get|post|put|delete|trace|options|connect|patch|head|redirect)\s+/i;
let verb = _.last(endpoint.match(verbExpr) || []) || '';
verb = verb.toLowerCase();