Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeRouter/afterRouter not needed to be validated for isArray #34

Open
killmenot opened this issue Nov 30, 2017 · 0 comments
Open

beforeRouter/afterRouter not needed to be validated for isArray #34

killmenot opened this issue Nov 30, 2017 · 0 comments

Comments

@killmenot
Copy link

Hi @robtweed

Please consider the following lines:

qewd/lib/master-express.js

Lines 95 to 102 in cbf87ac

var options = {
nextCallback: route.afterRouter ? true : false
};
args = args.concat([qx.router(options)]);
// add array with custom middleware to add after qx.router is called (if present)
if (route.afterRouter && Array.isArray(route.afterRouter)) args = args.concat(route.afterRouter);

Some notes:

  1. I'm not sure that beforeRouter/afterRouter must be validated to be an array because concat works fine if passed argument can be added to existing array -> [1, 2].concat(3) => [1, 2, 3]
  2. Another note is that, if we keep the current structure and declare beforeRouter/afterRouter as NOT an array, nextCallback can be set incorrectly (it will be true) but afterRouter won't be added

My proposal here is to allow developers to pass afterRouter as function of array of functions. In this case we do not need to validate beforeRouter/afterRouter for Array.isArray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant