This commit is contained in:
Julien Valverdé
2024-07-03 21:02:36 +02:00
parent 4e4b0ef156
commit 28136a4a91
10 changed files with 55 additions and 51 deletions

View File

@@ -0,0 +1,7 @@
import { initTRPC } from "@trpc/server"
import { Context, Layer } from "effect"
export class TRPCBuilder extends Context.Tag("TRPCBuilder")<TRPCBuilder, ReturnType<typeof initTRPC.create>>() {}
export const TRPCBuilderLive = Layer.sync(TRPCBuilder, () => initTRPC.create())

View File

@@ -0,0 +1,19 @@
import { Context, Effect, Layer, Runtime } from "effect"
import type { RuntimeFiber } from "effect/Fiber"
import { AppLive, type AppR } from "../App"
export class TRPCEffectRuntime extends Context.Tag("TRPCEffectRuntime")<TRPCEffectRuntime,
<A, E>(
self: Effect.Effect<A, E, AppR>,
options?: Runtime.RunForkOptions,
) => RuntimeFiber<A, E>
>() {}
export const TRPCEffectRuntimeLive = Layer.effect(TRPCEffectRuntime,
Effect.runtime<AppR>().pipe(
Effect.map(Runtime.runFork)
)
).pipe(
Layer.provide(AppLive)
)