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
)
})
)
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
)
})
)