chat-ui-agent-demo / src /lib /server /api /utils /superjsonResponse.ts
Mike0021's picture
Deploy verified chat and coding agent UX (part 2)
fae625a verified
Raw History Blame Contribute Delete
393 Bytes
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,
},
});
}