Router work
This commit is contained in:
@@ -11,6 +11,14 @@ export const todosRouter = Effect.gen(function*() {
|
||||
const procedure = yield* RPCProcedureBuilder
|
||||
|
||||
return t.router({
|
||||
all: procedure.query(({ ctx }) => ctx.run(Effect.gen(function*() {
|
||||
const todos = yield* TodoRepository
|
||||
|
||||
return yield* S.encode(S.Array(JsonifiableTodo))(
|
||||
yield* todos.todos.get
|
||||
)
|
||||
}))),
|
||||
|
||||
get: procedure
|
||||
.input(S.decodeUnknownSync(
|
||||
S.Struct({ id: S.String })
|
||||
@@ -22,17 +30,5 @@ export const todosRouter = Effect.gen(function*() {
|
||||
yield* todos.get(input.id)
|
||||
)
|
||||
}))),
|
||||
|
||||
getOrThrow: procedure
|
||||
.input(S.decodeUnknownSync(
|
||||
S.Struct({ id: S.String })
|
||||
))
|
||||
.query(({ ctx, input }) => ctx.run(Effect.gen(function*() {
|
||||
const todos = yield* TodoRepository
|
||||
|
||||
return yield* S.encode(JsonifiableTodo)(
|
||||
yield* yield* todos.get(input.id)
|
||||
)
|
||||
}))),
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user