15 lines
325 B
TypeScript
15 lines
325 B
TypeScript
export function jsonResponse(
|
|
body: unknown,
|
|
status: number,
|
|
headers: Record<string, string> = {},
|
|
): Response {
|
|
return new Response(JSON.stringify(body), {
|
|
status,
|
|
headers: {
|
|
"Content-Type": "application/json; charset=utf-8",
|
|
"X-Content-Type-Options": "nosniff",
|
|
...headers,
|
|
},
|
|
});
|
|
}
|