From Discord: Clarifying RPC Middleware Requirements and Usage in Effect TypeScript
Summary
The conversation centers around the design of RPC middleware in effect-ts, particularly why RpcMiddleware has no direct requirements in its type definition. It was clarified that the middleware can access required services by being provided those layers when the middleware is constructed, typically via Effects and Layers. This allows middleware to call services like UserSessionService despite the middleware type itself not declaring explicit requirements. Integration scenarios, such as using a custom runtime with frameworks (e.g., tanstack start) to maintain service lifetimes for streaming, were also discussed. Example code snippets demonstrated idiomatic layer construction providing middleware with dependencies, emphasizing proper usage over simplistic examples. Finally, the idea of improving RPC documentation to better explain these middleware patterns was suggested.
Discord thread
https://discord.com/channels/795981131316985866/1357837032960823316