HTTP server fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Context, Effect, Layer, Runtime } from "effect"
|
import { Context, Effect, Layer } from "effect"
|
||||||
import { Server } from "node:http"
|
import { Server } from "node:http"
|
||||||
import { ServerConfig } from "../ServerConfig"
|
import { ServerConfig } from "../ServerConfig"
|
||||||
import { ExpressApp } from "./ExpressApp"
|
import { ExpressApp } from "./ExpressApp"
|
||||||
@@ -9,14 +9,16 @@ export class ExpressHTTPServer extends Context.Tag("ExpressHTTPServer")<ExpressH
|
|||||||
export module ExpressHTTPServer {
|
export module ExpressHTTPServer {
|
||||||
export const Live = Layer.effect(ExpressHTTPServer, Effect.acquireRelease(
|
export const Live = Layer.effect(ExpressHTTPServer, Effect.acquireRelease(
|
||||||
Effect.gen(function*() {
|
Effect.gen(function*() {
|
||||||
const runSync = yield* Effect.runtime().pipe(
|
|
||||||
Effect.map(Runtime.runSync)
|
|
||||||
)
|
|
||||||
|
|
||||||
const app = yield* ExpressApp
|
const app = yield* ExpressApp
|
||||||
const port = yield* ServerConfig.httpPort
|
const port = yield* ServerConfig.httpPort
|
||||||
|
|
||||||
return app.listen(port, () => runSync(Effect.logInfo(`HTTP server listening on ${ port }`)))
|
return yield* Effect.async<Server>(resume => {
|
||||||
|
const server = app.listen(port, () => resume(
|
||||||
|
Effect.succeed(server).pipe(
|
||||||
|
Effect.tap(Effect.logInfo(`HTTP server listening on ${ port }`))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
})
|
||||||
}),
|
}),
|
||||||
|
|
||||||
server => Effect.gen(function*() {
|
server => Effect.gen(function*() {
|
||||||
|
|||||||
Reference in New Issue
Block a user