flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/sudo/app/entry.server.tsx

25 lines849 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Billing accounts, terms and enterprises; g1t is no longer free1import { renderToReadableStream } from "react-dom/server";
2import { type EntryContext, ServerRouter } from "react-router";
3
4/**
5 * Renders the whole page before sending it. sudo ships no JavaScript, so
6 * there is nothing to stream into and no inline script to allow.
7 */
8export default async function handleRequest(
9 request: Request,
10 responseStatusCode: number,
11 responseHeaders: Headers,
12 routerContext: EntryContext,
13) {
14 let status = responseStatusCode;
15 const body = await renderToReadableStream(<ServerRouter context={routerContext} url={request.url} />, {
16 signal: request.signal,
17 onError(error: unknown) {
18 status = 500;
19 console.error(error);
20 },
21 });
22 await body.allReady;
23 responseHeaders.set("content-type", "text/html; charset=utf-8");
24 return new Response(body, { headers: responseHeaders, status });
25}