Console app¶
Building the console app¶
The console under /app/ (the only console, see Console) is a React app in web/ (TypeScript strict, Vite, Tailwind 4,
TanStack Router, Query, Table and Virtual, Base UI, cmdk, ECharts modules). Exact versions
are pinned in web/package.json with package-lock.json. Node 24 or later is needed only
to change the app: its build output internal/server/webapp/dist is committed and embedded
with go:embed, so go build, go install, goreleaser and the Dockerfiles need no Node and
work air gapped. CI rebuilds the app and fails when the committed output differs.
make web # npm ci and build into internal/server/webapp/dist
make web-check # lint (eslint, tsc, translations), unit tests, build with bundle budget
make web-e2e E2E_DB=postgres://limdm@127.0.0.1:5432/limdm_e2e # Playwright: CSP and sign in
Inside web/:
| Command | Does |
|---|---|
npm run dev |
Vite dev server with a proxy to a local LiMDM server (below) |
npm run build |
type check, build, bundle budget (scripts/budget.mjs) |
npm run lint |
eslint, tsc -b, translation check (scripts/i18n-check.mjs) |
npm test |
Vitest unit tests (src/**/*.test.ts(x)) |
npm run e2e |
Playwright against a server it builds and starts itself |
npm run api |
regenerates src/api/schema.d.ts from internal/server/openapi.json |
npm run i18n |
keys per catalog, unused and missing keys |
The end to end tests need LIMDM_E2E_DATABASE_URL, a disposable PostgreSQL database (it gets
the schema, two local admins and a sealed session key in web/test-results/e2e). The setup
builds limdm-server, starts it with a throw away TLS certificate on https://localhost:18480
(LIMDM_E2E_PORT picks another port, for parallel runs in several worktrees) and signs in; e2e/csp.spec.ts fails on any CSP violation of any page or shared component
(/app/dev/components renders all of them) and checks that its detector works.
For the dev server, run the LiMDM server locally and point it at the dev server's origin
(LIMDM_PUBLIC_URL=https://localhost:5173, so the Origin check of the session API passes),
then start Vite with a local certificate: LIMDM_DEV_CERT=... LIMDM_DEV_KEY=...
LIMDM_DEV_BACKEND=https://localhost:8080 npm run dev. Sign in on the dev server's /login
and open /app/.
Rules the checks enforce:
- CSP:
default-src 'self', no inline script or style, no eval. zod compiles parsers withnew Functionunless it runs jitless, so every area importszfromsrc/lib/zod.ts, which sets that once; eslint refuses a directzodimport. - Translations: German and English for every text, one catalog per area
(
src/areas/<area>/messages.ts) plussrc/i18n/core.ts, French, Spanish, Italian and Russian inmessages.<lang>.tsandcore.<lang>.ts; tsc and the i18n test fail on a key missing in one language, the lint step on hardcoded visible text. The language follows the browser until the user picks one (Languages). - Bundle budget (gzip): first load 290 KB (the shell and the core catalog; area catalogs load with their routes), a lazy chunk 120 KB, ECharts 220 KB, CSS 20 KB, a font 100 KB.
- Shared building blocks live in
src/components(settings forms, blueprint picker, badges, downloads, data grid); an area imports another area's code only through its routes.
How the app talks to the server, the rules for the feature areas (file layout, routes, endpoints, schemas, translations, CSP) and the checks are in web/CONVENTIONS.md. The API it uses is in Console app.
xterm.js¶
The console terminal of the remote shell uses xterm.js with the fit and canvas addons,
vendored into internal/server/web/static/vendor/xterm and embedded in the server binary.
Without these files the session page shows that the terminal files are missing.
The script needs npm, fetches the exact versions pinned in it from the npm registry
(integrity checked by npm), and writes SHA256SUMS. Later runs refuse files that differ
from that file. Commit the directory. To update, change the versions in the script, delete
SHA256SUMS, run it and review the diff.
Swagger UI¶
The API reference at /api/v1/docs runs Swagger UI (swagger-ui-dist, Apache 2.0),
vendored into internal/server/web/static/vendor/swagger-ui (bundle, stylesheet, LICENSE,
NOTICE, VERSION, SHA256SUMS). The page itself is internal/server/apidocs.html, its
initializer and LiMDM styles are in internal/server/web/static/apidocs.
It works like the xterm.js script: exact version pinned in the script, refuses files that
differ from SHA256SUMS. Pick a release at least two weeks old. After changing
openapi.json, run npm run api in web to regenerate src/api/schema.d.ts;
TestOpenAPIOperations requires a declared tag, a summary, a security list and a unique
operation id on every operation.