Closed yacineb closed 3 years ago
The idea is good. I'm not sure if the API is intuitive enough. In arrays the .filter()
method excludes those elements where filter results in false
. In your API it's the opposite.
I would either rename the method to .bypass()
so that it's clear: bypass if true, or reverse the logic and also explain it clearer in the readme.
@yacineb what do you think?
btw in pr #41 there it is called excludeFn()
, although i'd rather go your way and bypass the entire middleware.
Also we need to make sure the /metrics
route remains no matter what the filter function says. One can remove it by a separate option.
@disjunction you"re right, i've changed the wording, documentation and added a test case.
Hope it will be accepted, i need this feature ASAP.
Thks & Regards
OK, thanks for the update. The test is broken, but I'll take it from here.
I've just published it at npm as version 6.3.0 Cheers!
Excluding routes by regexp is not handy. Using a filter lambda function is more powerful and generic. It enables instrumenting the api with custom criterias on requests (could be headers, routes etc) In production scenarios a public api is usually exposed to hackers who try to explore/scan routes, in few days the api has its registry full of 404, 403 metrics.