js-middleware icon indicating copy to clipboard operation
js-middleware copied to clipboard

Apply to all functions

Open davearata-snorack opened this issue 4 years ago • 2 comments

Added functionality so that if you pass null as the first parameter tomiddlewaremanager.use it will apply the middleware to all functions in the given object.

davearata-snorack avatar Jun 22 '21 21:06 davearata-snorack

@unbug any chance this can be reviewed and merged?

davearata-snorack avatar Nov 11 '21 22:11 davearata-snorack

Sorry @davearata-snorack , I prefer not to take advantage of the params. I suggest you could do :

Object.getOwnPropertyNames(Person.prototype).forEach(method => {
  if(method !== 'constructor') {
      middlewareManager.use(method, logger);
  }
});

unbug avatar Dec 22 '21 12:12 unbug