mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 12:54:42 +00:00
refactor(question): use effectful HttpApi group builder
Build the question HttpApi handlers with an effectful group callback so the service is resolved once at layer construction time and the endpoint handlers close over the resulting service methods.
This commit is contained in:
parent
5a2737d233
commit
a4c8d0588e
1 changed files with 5 additions and 3 deletions
|
|
@ -50,8 +50,10 @@ const Api = HttpApi.make("question")
|
|||
}),
|
||||
)
|
||||
|
||||
const QuestionLive = Layer.unwrap(
|
||||
Effect.gen(function* () {
|
||||
const QuestionLive = HttpApiBuilder.group(
|
||||
Api,
|
||||
"question",
|
||||
Effect.fn("QuestionHttpApi.handlers")(function* (handlers) {
|
||||
const svc = yield* Question.Service
|
||||
|
||||
const list = Effect.fn("QuestionHttpApi.list")(function* () {
|
||||
|
|
@ -69,7 +71,7 @@ const QuestionLive = Layer.unwrap(
|
|||
return true
|
||||
})
|
||||
|
||||
return HttpApiBuilder.group(Api, "question", (handlers) => handlers.handle("list", list).handle("reply", reply))
|
||||
return handlers.handle("list", list).handle("reply", reply)
|
||||
}),
|
||||
).pipe(Layer.provide(Question.defaultLayer))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue