Integrating fastify with effect

Hey everyone, I have a question I'm still wrapping my mind around all these new concepts with effect (coming from fp-ts), I saw the express integration example in the effect docs and I've decided to try and that but with fastify
Now, since in fastify the listen function is a promise, how would I then change the example code ? I initially thought that I'll need to change the Effect.sync into Effect.async but turns out these are completely different things with different purposes?
also, fastify uses async functions for it's routes (see examples below), how would I treat these ?
interface IndexRouteReturnValue {
    hello: string
}

const IndexRouteLive = Layer.effectDiscard(
    Effect.gen(function *() {
        const app = yield* Fastify
        const runFork = Runtime.runFork(yield* Effect.runtime<IndexRouteReturnValue>())

                      // this should be a promise but Effect.async does not solves this.
        app.get('/', runFork(Effect.sync(() => ({ hello: 'world' }))))
    })
)


const ServerLive = Layer.scopedDiscard(
  Effect.gen(function* () {
    const port = 3001
    const app = yield* Fastify
    yield* Effect.acquireRelease(
      Effect.sync(() =>
        app.listen({ port })
      ),
      (server) => Effect.sync(() => server.close()) // this also needs to be async
    )
  })
)


any help would be much appreciated.
Was this page helpful?