@@ -3,39 +3,27 @@ import { memoMap } from "@/effect/run-service"
33import { Question } from "@/question"
44import { QuestionID } from "@/question/schema"
55import { lazy } from "@/util/lazy"
6- import { QuestionReply , QuestionRequest , questionApi } from "@opencode-ai/server"
7- import { Effect , Layer , Schema } from "effect"
6+ import { makeQuestionHandler , questionApi } from "@opencode-ai/server"
7+ import { Effect , Layer } from "effect"
88import { HttpRouter , HttpServer } from "effect/unstable/http"
99import { HttpApiBuilder } from "effect/unstable/httpapi"
1010import type { Handler } from "hono"
1111
1212const root = "/experimental/httpapi/question"
1313
14- const QuestionLive = HttpApiBuilder . group (
15- questionApi ,
16- "question" ,
17- Effect . fn ( "QuestionHttpApi.handlers" ) ( function * ( handlers ) {
14+ const QuestionLive = makeQuestionHandler ( {
15+ list : Effect . fn ( "QuestionHttpApi.host.list" ) ( function * ( ) {
1816 const svc = yield * Question . Service
19- const decode = Schema . decodeUnknownSync ( Schema . Array ( QuestionRequest ) )
20-
21- const list = Effect . fn ( "QuestionHttpApi.list" ) ( function * ( ) {
22- return decode ( yield * svc . list ( ) )
23- } )
24-
25- const reply = Effect . fn ( "QuestionHttpApi.reply" ) ( function * ( ctx : {
26- params : { requestID : string }
27- payload : Schema . Schema . Type < typeof QuestionReply >
28- } ) {
29- yield * svc . reply ( {
30- requestID : QuestionID . make ( ctx . params . requestID ) ,
31- answers : ctx . payload . answers ,
32- } )
33- return true
17+ return yield * svc . list ( )
18+ } ) ,
19+ reply : Effect . fn ( "QuestionHttpApi.host.reply" ) ( function * ( input ) {
20+ const svc = yield * Question . Service
21+ yield * svc . reply ( {
22+ requestID : QuestionID . make ( input . requestID ) ,
23+ answers : input . answers ,
3424 } )
35-
36- return handlers . handle ( "list" , list ) . handle ( "reply" , reply )
3725 } ) ,
38- ) . pipe ( Layer . provide ( Question . defaultLayer ) )
26+ } ) . pipe ( Layer . provide ( Question . defaultLayer ) )
3927
4028const web = lazy ( ( ) =>
4129 HttpRouter . toWebHandler (
0 commit comments