feathers-hooks-common
feathers-hooks-common copied to clipboard
[feature idea]: sequential every and some hooks
Hello guys,
I'm submitting the basic idea here and once you approve it, I'll add the PR with types and tests et al.
The current every and some hooks run the input hooks in parallel, but the problem with that approach is that we can't take advantage of short-circuiting.
For example, if we want to make sure the user is:
- is authenticated
- AND has access to the resource
Using the existing every hook, both checks will run for every request.
But if we had a everySeq hook for example, if the user is not authenticated, we can run the first check only and directly return an error.
Of course, for a small example like this, it wouldn't make much difference. But sometimes, one of the checks could be resource-intensive and we'd would want to live it till the end to avoid running for most requests.
What do you think ?