From f725fb194f3ac03d7b3c4ae18a7089bf7670b993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Fri, 5 Jul 2024 01:44:46 +0200 Subject: [PATCH] Server test --- packages/server/src/index.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 92f72f3..eaaba6c 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -1,10 +1,16 @@ import { BunRuntime } from "@effect/platform-bun" import { Todo } from "@todo-tests/common/data" import { Identifiable } from "@todo-tests/common/traits" -import { Array, Duration, Effect, Fiber, Layer, Option, Stream } from "effect" +import { Array, Duration, Effect, Layer, Option, Stream } from "effect" import { ServicesLive } from "./Services" import { TodoRepository, createDefaultTodos } from "./TodoRepository" -import { TRPCEffectRuntimeLive } from "./trpc/TRPCEffectRuntime" +import { ExpressApp } from "./express/ExpressApp" +import { ExpressHTTPServer } from "./express/ExpressHTTPServer" + + +const ServerLive = ExpressHTTPServer.Live.pipe( + Layer.provide(ExpressApp.Live) +) const watchTodoChanges = Effect.gen(function*() { @@ -24,7 +30,6 @@ const watchTodoChanges = Effect.gen(function*() { ) }) - const main = Effect.gen(function*() { const watcher = yield* Effect.fork(watchTodoChanges) yield* createDefaultTodos @@ -52,16 +57,14 @@ const main = Effect.gen(function*() { Effect.delay(Duration.seconds(1)) ) - yield* Fiber.join(watcher) + // yield* Fiber.join(watcher) + yield* Layer.launch(ServerLive) }) -const runnableMain = main.pipe( +BunRuntime.runMain(main.pipe( Effect.provide( Layer.mergeAll( - ServicesLive, - TRPCEffectRuntimeLive, + ServicesLive ) ) -) - -BunRuntime.runMain(runnableMain) +))