diff --git a/src/index.ts b/src/index.ts index c98dc45b0..52bfb8b9d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -121,32 +121,29 @@ const expressServer = app({ class Express extends Context.Tag('Express')>() {} -NodeRuntime.runMain( - Layer.launch( - pipe( - Layer.scopedDiscard( - Effect.acquireRelease( - Effect.gen(function* () { - const app = yield* Express - const listeningHttpServer = app.listen(3000) - L.debug('Server listening')(loggerEnv)() - return listeningHttpServer - }), - server => - Effect.promise(async () => { - L.debug('Shutting server down')(loggerEnv)() - server.close() +pipe( + Effect.acquireRelease( + Effect.gen(function* () { + const app = yield* Express + const listeningHttpServer = app.listen(3000) + L.debug('Server listening')(loggerEnv)() + return listeningHttpServer + }), + server => + Effect.promise(async () => { + L.debug('Shutting server down')(loggerEnv)() + server.close() - await redis - .quit() - .then(() => L.debug('Redis disconnected')(loggerEnv)()) - .catch((error: unknown) => - L.warnP('Redis unable to disconnect')({ error: E.toError(error).message })(loggerEnv)(), - ) - }), - ), - ), - Layer.provide(Layer.sync(Express, () => expressServer)), - ), + await redis + .quit() + .then(() => L.debug('Redis disconnected')(loggerEnv)()) + .catch((error: unknown) => + L.warnP('Redis unable to disconnect')({ error: E.toError(error).message })(loggerEnv)(), + ) + }), ), + Layer.scopedDiscard, + Layer.provide(Layer.sync(Express, () => expressServer)), + Layer.launch, + NodeRuntime.runMain, )