Using a Generic Service for Request Data in Effect Typescript
I am doing something weird with a "generic service" and I wonder what you think about it and if there is a more standard approach.
I provide this service with
It is when I test the endpoint that I use
As a bonus I can see the input type when hovering over my endpoint. I could create an Endpoint type alias with an additional channel and make the distinction more clear between the Effect requirement, which is actually just
It all seems very ad hoc though
I provide this service with
Effect.provideService as usual when interpreting an endpoint as a Promise for Remix to consume. The endpoint is just an Effect querying some services and RequestData is one of them.It is when I test the endpoint that I use
RequestData.provideService, so that my input is type checked and auto-completed.As a bonus I can see the input type when hovering over my endpoint. I could create an Endpoint type alias with an additional channel and make the distinction more clear between the Effect requirement, which is actually just
RequestData (that's what I find confusing about the whole pattern, the generic is not part of the requirement, the effect would just fail with a ParseError), and the Endpoint expected input.It all seems very ad hoc though
