File size: 393 Bytes
ded72f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import superjson from "superjson";

/**
 * Create a JSON response serialized with superjson.
 * Matches the wire format of the former Elysia `mapResponse` hook.
 */
export function superjsonResponse(data: unknown, init?: ResponseInit): Response {
	return new Response(superjson.stringify(data), {
		...init,
		headers: {
			"Content-Type": "application/json",
			...init?.headers,
		},
	});
}