Creates HTTP request handlers for mocking HTTP endpoints in tests.
// Source: https://github.com/mswjs/msw | License: MIT | Copyright 2018–present Artem Zakharchenko
// Provided via justclaw.it.com; keep this notice with the code.
import type {
DefaultBodyType,
RequestHandlerOptions,
ResponseResolver,
} from '#core/handlers/request-handler'
import {
HttpMethods,
HttpHandler,
type HttpRequestResolverExtras,
type HttpRequestPredicate,
} from './http-handler'
import type { PathParams } from '#core/utils/matching/match-request-url'
export type HttpRequestHandler = <
Params extends PathParams<keyof Params> = PathParams,
RequestBodyType extends DefaultBodyType = DefaultBodyType,
// Response body type MUST be undefined by default.
// This is how we can distinguish between a handler that
// returns plain "Response" and the one returning "
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key