11 lines
308 B
TypeScript
11 lines
308 B
TypeScript
// lib/json.ts
|
|
export function json(data: unknown, init?: ResponseInit) {
|
|
return new Response(
|
|
JSON.stringify(data, (_k, v) => (typeof v === 'bigint' ? v.toString() : v)),
|
|
{
|
|
...init,
|
|
headers: { 'content-type': 'application/json; charset=utf-8', ...(init?.headers || {}) },
|
|
}
|
|
);
|
|
}
|