14 lines
462 B
TypeScript
14 lines
462 B
TypeScript
export type Body = ConstructorParameters<typeof Response>[0];
|
|
export type ResponseOptions = ConstructorParameters<typeof Response>[1];
|
|
|
|
export function badRequest(body?: Body, options?: ResponseOptions): Response {
|
|
return new Response(body, { status: 400, ...options });
|
|
}
|
|
|
|
export function html(body: Body, options?: ResponseOptions): Response {
|
|
return new Response(body, {
|
|
...options,
|
|
headers: { 'Content-Type': 'text/html', ...options?.headers },
|
|
});
|
|
}
|