- collapse run log data blocks whose pretty-printed JSON exceeds a byte or line limit, with a per-block toggle and an expand/collapse-all button next to the Logs heading - align data blocks and toggles with the context/message column - add a "Copy logs" button that copies the filtered logs as plain text with every data block expanded - add GET /manifest.json with the app name, version and run log data limits (RUN_LOG_DATA_COLLAPSE_BYTES / RUN_LOG_DATA_COLLAPSE_LINES) - load the manifest in the client stale-while-revalidate: localStorage copy first, refetched per page load and on tab focus after a while - show the server version in the sidebar footer, with a reload hint when it differs from the client build Closes #3
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import type { ServeStaticModuleOptions } from "@nestjs/serve-static";
|
|
import type { ServerResponse } from "node:http";
|
|
import * as path from "node:path";
|
|
|
|
/** Server routes that must never fall back to the client's index.html. */
|
|
const SERVER_ROUTES = [
|
|
"/api/{*path}",
|
|
"/mcp{*path}",
|
|
"/docs{*path}",
|
|
"/health",
|
|
"/healthz",
|
|
"/manifest.json",
|
|
];
|
|
|
|
/**
|
|
* Serves the built client (SPA) from `clientDir`: static files as they are,
|
|
* any other GET outside the server routes gets index.html so client-side
|
|
* routes survive a page refresh. Returns no options (nothing served) when
|
|
* `clientDir` is empty, e.g. in tests and local development.
|
|
*/
|
|
export function clientStaticOptions(
|
|
clientDir: string,
|
|
): ServeStaticModuleOptions[] {
|
|
if (!clientDir) return [];
|
|
return [
|
|
{
|
|
rootPath: path.resolve(clientDir),
|
|
exclude: SERVER_ROUTES,
|
|
serveStaticOptions: {
|
|
setHeaders: (res: ServerResponse, filePath: string) => {
|
|
// Vite emits content-hashed files under assets/; index.html must
|
|
// always be revalidated so a new deploy is picked up immediately
|
|
const cacheControl = filePath.includes(`${path.sep}assets${path.sep}`)
|
|
? "public, max-age=31536000, immutable"
|
|
: "no-cache";
|
|
res.setHeader("Cache-Control", cacheControl);
|
|
},
|
|
},
|
|
},
|
|
];
|
|
}
|