Integrate auth, config, watcher and terminal wiring in buildApp: auth guards every API route by default, notebook watcher events feed the /api/events hub, the terminal runs in the configured workspace, and SHELLBOOK_DATA_DIR is the single data directory variable. The systemd unit uses KillMode=process so tmux sessions survive service restarts.
24 lines
784 B
TypeScript
24 lines
784 B
TypeScript
import { buildApp } from "./app";
|
|
import { loadConfig } from "./config";
|
|
|
|
const host = process.env.SHELLBOOK_HOST ?? "127.0.0.1";
|
|
const port = Number(process.env.SHELLBOOK_PORT ?? 8080);
|
|
|
|
const proxies = process.env.SHELLBOOK_TRUSTED_PROXIES?.split(",").map(ip => ip.trim()).filter(Boolean) ?? [];
|
|
const config = loadConfig();
|
|
const app = await buildApp({
|
|
logger: true,
|
|
config,
|
|
trustProxy: proxies,
|
|
staticDir: process.env.SHELLBOOK_STATIC_DIR,
|
|
watchNotebooks: true,
|
|
auth: {
|
|
sessionMaxAgeSeconds: Number(process.env.SHELLBOOK_SESSION_SECONDS ?? 2592000),
|
|
forwardAuth: process.env.SHELLBOOK_FORWARD_AUTH_HEADER ? {
|
|
header: process.env.SHELLBOOK_FORWARD_AUTH_HEADER,
|
|
trustedProxyIps: proxies,
|
|
} : undefined,
|
|
},
|
|
});
|
|
await app.listen({ host, port });
|