IdoPesok / zsa

https://zsa.vercel.app
MIT License
762 stars 23 forks source link

Chaining procedure #203

Open blechatellier opened 4 weeks ago

blechatellier commented 4 weeks ago

This is a suggestion for chaining procedure, it would be good to have a .use() instead of having to pass the chained procedure as an argument to another procedure, makes things a bit difficult to nest.

IdoPesok commented 3 weeks ago

Hi, can you share an example to showcase current limitations and where .use will shine? Will help me understand the root problem.

blechatellier commented 3 weeks ago

I have a procedure for logging, one for checking user auth, another one for rate limiting.

At the moment I need to do something like loggingProcedure(authProcedure(rateLimitingProcedure)). If I want to pass in some arguments to the procedure (ie: roles to check for auth), I need to nest them loggingProcedure(authProcedure(roles)(rateLimitingProcedure)). It's all possible to do as it is but a chaining method like .use() would help for readability and composability.