MCPcopy Index your code
hub / github.com/anomalyco/opencode / app

Function app

packages/opencode/test/server/httpapi-exercise/backend.ts:53–78  ·  view source on GitHub ↗
(modules: Runtime, options: CallOptions)

Source from the content-addressed store, hash-verified

51}
52
53function app(modules: Runtime, options: CallOptions) {
54 const username = options.auth?.username
55 const password = options.auth?.password
56 const cacheKey = `${username ?? ""}:${password ?? ""}`
57 if (appCache[cacheKey]) return appCache[cacheKey]
58
59 const web = HttpRouter.toWebHandler(
60 modules.HttpApiApp.routes.pipe(
61 Layer.provide(
62 ConfigProvider.layer(
63 ConfigProvider.fromUnknown({ OPENCODE_SERVER_PASSWORD: password, OPENCODE_SERVER_USERNAME: username }),
64 ),
65 ),
66 ),
67 { disableLogger: true, memoMap: modules.memoMap },
68 )
69 return (appCache[cacheKey] = {
70 dispose: web.dispose,
71 request(input: string | URL | Request, init?: RequestInit) {
72 return web.handler(
73 input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init),
74 modules.HttpApiApp.context,
75 )
76 },
77 })
78}
79
80function toRequest(scenario: ActiveScenario, ctx: SeededContext<unknown>) {
81 const spec = scenario.request(ctx, ctx.state)

Callers 2

callFunction · 0.70
callAuthProbeFunction · 0.70

Calls 1

layerMethod · 0.45

Tested by

no test coverage detected