(modules: Runtime, options: CallOptions)
| 51 | } |
| 52 | |
| 53 | function 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 | |
| 80 | function toRequest(scenario: ActiveScenario, ctx: SeededContext<unknown>) { |
| 81 | const spec = scenario.request(ctx, ctx.state) |
no test coverage detected