serve: inline node listen options

This commit is contained in:
Dax Raad 2026-05-16 00:49:27 -04:00
parent d1f44d4cd2
commit cb45de6fd2

View file

@ -250,7 +250,10 @@ function serverLayer(opts: ListenOptions) {
}) as typeof server.close
return Layer.mergeAll(
NodeHttpServer.layer(() => server, nodeListenOptions(opts)),
NodeHttpServer.layer(() => server, {
...(opts.type === "socket" ? { path: opts.socket } : { port: opts.port, host: opts.hostname }),
gracefulShutdownTimeout: "1 second",
}),
Layer.succeed(ListenerServerService)(
ListenerServerService.of({
closeAll: Effect.sync(() => {
@ -262,9 +265,4 @@ function serverLayer(opts: ListenOptions) {
)
}
function nodeListenOptions(opts: ListenOptions) {
if (opts.type === "socket") return { path: opts.socket, gracefulShutdownTimeout: "1 second" as const }
return { port: opts.port, host: opts.hostname, gracefulShutdownTimeout: "1 second" as const }
}
export * as Server from "./server"