RPC work
This commit is contained in:
7
packages/server/src/trpc/TRPCBuilder.ts
Normal file
7
packages/server/src/trpc/TRPCBuilder.ts
Normal 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())
|
||||
19
packages/server/src/trpc/TRPCEffectRuntime.ts
Normal file
19
packages/server/src/trpc/TRPCEffectRuntime.ts
Normal 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)
|
||||
)
|
||||
Reference in New Issue
Block a user