MCPcopy Create free account
hub / github.com/pollinations/pollinations / createHonoMockHandler

Function createHonoMockHandler

shared/test/mocks/fetch.ts:20–34  ·  view source on GitHub ↗
(handler: Hono)

Source from the content-addressed store, hash-verified

18};
19
20export function createHonoMockHandler(handler: Hono): MockHandler {
21 return async (request: Request) => {
22 const url = new URL(request.url);
23 // trim trailing slashes
24 url.pathname = url.pathname.endsWith("/")
25 ? url.pathname.slice(0, -1)
26 : url.pathname;
27 const mockRequest = new Request(url, {
28 method: request.method,
29 headers: request.headers,
30 body: request.body,
31 });
32 return await handler.fetch(mockRequest);
33 };
34}
35
36type FetchMockOptions = {
37 logRequests?: boolean;

Callers 4

createMockVcrFunction · 0.90
createMockTinybirdFunction · 0.90
createMockGithubFunction · 0.90
createMockStripeFunction · 0.90

Calls 2

sliceMethod · 0.80
fetchMethod · 0.65

Tested by

no test coverage detected