kareem
kareem copied to clipboard
BREAKING CHANGE: make execPre async and drop callback support
Work in progress to make execPre() and execPost() use async functions where possible to better support https://github.com/Automattic/mongoose/issues/15317. Tested in kareem repo as well as running Mongoose with these changes.
Couple of breaking changes in this PR:
- No longer support passing arguments to the next middleware. Previously, you could do
next(null, 'new arg')and the args to the next middleware would get overwritten by 'new arg'. - No more callback support for
execPre() - Errors take precedence over
next()calls. If your middleware function does something likenext(); throw new Error('Fail');, this new logic will treat the middleware function as errored with error 'Fail'. Kareem@2 ignores the 'Fail' error.
@hasezoey your feedback would be much appreciated.