Challenges with Middleware Error Propagation and Modular API Design in HttpApi
In the current design of HttpApi, middleware can pollute the entire API with potential errors, even when it's only attached to a subset of routes. I also don't understand why middleware errors propagate to handlers. Shouldn't an error in middleware mean that the handler doesn't need to be worried about it? Because a failure in middleware means that the request is not processed further.
My goal is to create standalone packages for different API groups, with a central package to collect and serve them as a single API. It's quite easy to design a description of your API in different modules and then combine them, but the problem is with LiveImplementation. My first idea was that each package could export GroupLiveImplementation, but it doesn't work. The root API is not satisfied if you provide it with a Live Implementation that was created based on the group and not the entire API. My second idea was to export all handlers that can implement the live layer later. In my core package, I can just make a live implementation reusing all handlers. This only works if you don't have any middleware in the entire tree of routes that creates failures.
Here is the code
https://effect.website/play/#8e70df5ec9cc
My goal is to create standalone packages for different API groups, with a central package to collect and serve them as a single API. It's quite easy to design a description of your API in different modules and then combine them, but the problem is with LiveImplementation. My first idea was that each package could export GroupLiveImplementation, but it doesn't work. The root API is not satisfied if you provide it with a Live Implementation that was created based on the group and not the entire API. My second idea was to export all handlers that can implement the live layer later. In my core package, I can just make a live implementation reusing all handlers. This only works if you don't have any middleware in the entire tree of routes that creates failures.
Here is the code
https://effect.website/play/#8e70df5ec9cc
