tRPC work

This commit is contained in:
Julien Valverdé
2024-07-02 01:58:21 +02:00
parent 07f5701206
commit e2f357b4bb

View File

@@ -5,19 +5,26 @@ import { TodoRepository } from "./TodoRepository"
export const t = initTRPC.create() export const t = initTRPC.create()
export const run = <A, E, R>( export const run = <
program: Effect.Effect<A, E, R> Args extends unknown[],
A, E, R
>(
program: (...args: Args) => Effect.Effect<A, E, R>
) => FiberSet.makeRuntime<R>().pipe( ) => FiberSet.makeRuntime<R>().pipe(
Effect.map(runFork => runFork(program)) Effect.map(runFork =>
(...args: Args) => runFork(program(...args))
)
) )
const testRouter = Effect.gen(function*() { const testRouter = Effect.gen(function*() {
return t.router({ return t.router({
test: t.procedure.query(() => test: t.procedure.query(
yield* run(Effect.gen(function*() { yield* run((opts) => Effect.gen(function*() {
const todos = yield* TodoRepository const todos = yield* TodoRepository
return "test" return "test"
})) }))
) ),
test2: t.procedure.query(opts => {}),
}) })
}) })