mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-09 20:01:15 +02:00
36 lines
934 B
TypeScript
36 lines
934 B
TypeScript
import {
|
|
createTemporaryReferenceSet,
|
|
decodeAction,
|
|
decodeFormState,
|
|
decodeReply,
|
|
loadServerAction,
|
|
renderToReadableStream,
|
|
} from "@vitejs/plugin-rsc/rsc";
|
|
import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
import { routes } from "../app/routes";
|
|
|
|
export function fetchServer(request: Request) {
|
|
return matchRSCServerRequest({
|
|
// Provide the React Server touchpoints.
|
|
createTemporaryReferenceSet,
|
|
decodeAction,
|
|
decodeFormState,
|
|
decodeReply,
|
|
loadServerAction,
|
|
// The incoming request.
|
|
request,
|
|
// The app routes.
|
|
routes,
|
|
// Encode the match with the React Server implementation.
|
|
generateResponse(match, options) {
|
|
return new Response(renderToReadableStream(match.payload, options), {
|
|
status: match.statusCode,
|
|
headers: match.headers,
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
if (import.meta.hot) {
|
|
import.meta.hot.accept();
|
|
}
|