Open rvndev opened 3 days ago
Thought of that before, but it wasn't too difficult to achieve that in the current state, by chaining multiple middlewares (or functions, which they simply are). Maybe we can have a helper function like chainMiddlewares(midlewareOne, middlewareTwo, ...)
, so it will look something like
serverAct
.middleware(chainMiddleware(middlewareOne, middlewareTwo, ...))
.action(...)
I also thought of chaining middleware like serverAct.middleware(...).middleware(...).action(...)
, but I worry about if this will create any overhead. I might be overthinking, but feedbacks are welcome🙂
More on the chaining middleware, it could be challenging to make it type-safe as well.
Before we have an actual middleware chaining implementation, we will prevent people from chaining multiple duplicate methods at type-level in #27.
Currently,
server-act
overwrites previous context when chaining multiple middlewares. It would be very useful if, instead of the current behaviour, all middleware contexts were merged.I was trying to extend
server-act
to do this, however, I am not a TypeScript wizard and was running into issues when trying to preserve type safety.I was wondering if you would like to help me with the type safety feature?