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

Function app

packages/opencode/test/server/httpapi-instance-route-auth.test.ts:12–33  ·  view source on GitHub ↗
(input: { password?: string; username?: string })

Source from the content-addressed store, hash-verified

10import { disposeAllInstances, tmpdir } from "../fixture/fixture"
11
12function app(input: { password?: string; username?: string }) {
13 const handler = HttpRouter.toWebHandler(
14 HttpApiApp.routes.pipe(
15 Layer.provide(
16 ConfigProvider.layer(
17 ConfigProvider.fromUnknown({
18 OPENCODE_SERVER_PASSWORD: input.password,
19 OPENCODE_SERVER_USERNAME: input.username,
20 }),
21 ),
22 ),
23 ),
24 { disableLogger: true },
25 ).handler
26
27 return {
28 fetch: (request: Request) => handler(request, HttpApiApp.context),
29 request(input: string | URL | Request, init?: RequestInit) {
30 return this.fetch(input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init))
31 },
32 }
33}
34
35function basic(username: string, password: string) {
36 return ServerAuth.header({ username, password }) ?? ""

Calls 2

handlerFunction · 0.70
layerMethod · 0.45

Tested by

no test coverage detected