mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Replace the server-level `--demo` flag with per-request demo dispatch. The Rust API builds both a demo and real router; incoming requests with the `X-Arc-Demo: 1` header hit the demo router (auth disabled, static data), all others hit the real router with normal auth. The React web app gets a beaker icon toggle in the top nav bar (next to the theme toggle) that sets an `arc-demo` cookie. Loaders read the cookie to decide whether to send the `X-Arc-Demo: 1` header to the API. The `ARC_DEMO=1` env var still works as a default when no cookie is set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
913 B
TypeScript
44 lines
913 B
TypeScript
const service = process.argv[2];
|
|
|
|
type ServiceConfig = {
|
|
command: string[];
|
|
cwd?: string;
|
|
};
|
|
|
|
const services: Record<string, ServiceConfig> = {
|
|
api: {
|
|
command: ["arc", "serve", "--host", "0.0.0.0"],
|
|
},
|
|
web: {
|
|
command: ["bun", "run", "dev", "--host", "0.0.0.0"],
|
|
cwd: "apps/arc-web",
|
|
},
|
|
docs: {
|
|
command: ["mintlify", "dev", "--port", "3333", "--host", "0.0.0.0"],
|
|
cwd: "docs",
|
|
},
|
|
};
|
|
|
|
const validServices = Object.keys(services).join("|");
|
|
|
|
if (!service) {
|
|
console.error(`Usage: docker run arc <${validServices}>`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const config = services[service];
|
|
if (!config) {
|
|
console.error(
|
|
`Unknown service: ${service}. Use one of: ${Object.keys(services).join(", ")}`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const child = Bun.spawn(config.command, {
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
stdin: "inherit",
|
|
cwd: config.cwd,
|
|
});
|
|
|
|
process.exit(await child.exited);
|