Handling Service Provision in Express Endpoints with Effect

So I'm trying to do the express example from the website. I've got my effect working and generating the hello-world response. That part is fine 🙂

I have a layer which defines my logging service, which has been provided to the top-level runtime, because express endpoints are running on another fiber, I don't have that service provided. Just wondering what the correct way to handle this is?

I assume do an import of the logging service and do another
Effect.provide
, but wanted to check. I'm working in an extendable environment which doesn't necessarily know all the layers provided to the current runtime, is there a way to get the current runtime's services and pass it to this fork?

const helloWorld = Effect.gen( function* () {
    const app = yield* Express
    const runtime = yield* Effect.runtime()

    app.get(
        '/',
        (
            _,
            res
        ) => {
            Effect.runSync(
                Effect.gen( function* () {
                    // const Console = yield* ConsoleService
                    // yield* Console.warn( 'Ran hello world' )
                    return res.send( 'Hello World!' )
                } )
            )
        }
    )
} )
Was this page helpful?