MCPcopy
hub / github.com/anomalyco/opencode / uiApp

Function uiApp

packages/opencode/test/server/httpapi-ui.test.ts:89–128  ·  view source on GitHub ↗
(input?: {
  password?: string
  username?: string
  client?: Layer.Layer<HttpClient.HttpClient>
  disableEmbeddedWebUi?: boolean
})

Source from the content-addressed store, hash-verified

87}
88
89function uiApp(input?: {
90 password?: string
91 username?: string
92 client?: Layer.Layer<HttpClient.HttpClient>
93 disableEmbeddedWebUi?: boolean
94}) {
95 const handler = HttpRouter.toWebHandler(
96 HttpRouter.use((router) =>
97 Effect.gen(function* () {
98 const fs = yield* FSUtil.Service
99 const client = yield* HttpClient.HttpClient
100 const flags = yield* RuntimeFlags.Service
101 yield* router.add("*", "/*", (request) =>
102 serveUIEffect(request, { fs, client, disableEmbeddedWebUi: flags.disableEmbeddedWebUi }),
103 )
104 }),
105 ).pipe(
106 Layer.provide(authorizationRouterMiddleware.layer.pipe(Layer.provide(authConfigLayer(input)))),
107 Layer.provide([
108 fsUtilLayer,
109 input?.client ?? httpClient(new Response("ui")),
110 RuntimeFlags.layer({ disableEmbeddedWebUi: input?.disableEmbeddedWebUi ?? false }),
111 HttpServer.layerServices,
112 ]),
113 ),
114 { disableLogger: true },
115 ).handler
116 return {
117 request(input: string | URL | Request, init?: RequestInit) {
118 return Effect.promise(() =>
119 Promise.resolve(
120 handler(
121 input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init),
122 HttpApiApp.context,
123 ),
124 ),
125 )
126 },
127 }
128}
129
130function routeOrderingApp() {
131 let proxiedUrl: string | undefined

Callers 1

httpapi-ui.test.tsFile · 0.85

Calls 6

serveUIEffectFunction · 0.90
authConfigLayerFunction · 0.85
httpClientFunction · 0.85
addMethod · 0.65
useMethod · 0.45
layerMethod · 0.45

Tested by

no test coverage detected