Handling Middleware in Express with Effect

in effect - if i'm wrapping Express, I'm curious on the "effect" way of handling middleware

// Define Express as a service
class Express extends Context.Tag('Express')<Express, ReturnType<typeof express>>() {}

const ExpressLive = Layer.succeed(Express, express());
export { Express, ExpressLive };


If I want to set middleware in Express, we use app.use, would it be best to a) implement the middleware inside of this service, for middleware I want on "every" route?

Is it just better to require this service in the route and more verbosely put each middleware on a route by route basis?

Or is something that I would handle in the ServerLive function, where i'm defining the entire server and then "merging" routes into here?
Was this page helpful?