INNER CODE UNIT · TypeScript

send

yvgude/lean-ctx · packages/vscode-lean-ctx/src/bridge/server.ts:23

function send(res: http.ServerResponse, status: number, body: unknown): void {
  const text = JSON.stringify(body);
  res.writeHead(status, {
    "Content-Type": "application/json",
    "Content-Length": Buffer.byteLength(text),
    Connection: "close",
  });
  res.end(text);
}

/**
 * Serves `root` on `127.0.0.1` (ephemeral port). Every request must carry
 * `X-LeanCtx-Token: <token>`; anything else gets 401 before it is read.
 */
export function startBridge(opts: {
  root: string;
  token: string;
  navigator: Navigator;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…