Start the server in any HAXsite or HAXcms instance
New to the HAX ecosystem? Start here — the single onboarding guide covers prerequisites, cloning the core repos, installing, and running each project locally.
- Faculty, instructors, and course designers — author course sites, OER materials, and microsites in the browser with HAX, then publish them anywhere.
- Instructional designers and content teams — build accessible, standards-based pages out of web components, with no build tooling to maintain.
- Campus IT and system administrators — a self-hosted, database-free Node.js backend: flat files, git-backed publishing, an OpenAPI-documented, JWT-authenticated v1 REST API (conformance-tested), and configuration-driven deployment profiles.
- Students and learners — consume fast, offline-capable, WCAG-aligned static sites on any device.
- Desktop and CLI users — this backend is the engine wrapped by the HAX desktop app and driven by the
haxCLI.
npm install
npm startVisit http://localhost:3000 if it doesn't automatically open
HAXCMS_HOSTsets the interface the server listens on (e.g.127.0.0.1,0.0.0.0,::, or a specific address). When unset, the server listens on all interfaces — except in no-login mode.- No-login mode (
npx @haxtheweb/haxcms-nodejs,npm run dev:nologin, i.e.HAXCMS_DISABLE_JWT_CHECKS) binds127.0.0.1only, so an unauthenticated instance is not reachable from other machines. To deliberately expose it on your LAN setHAXCMS_HOST=0.0.0.0; a loud warning is printed because anyone who can reach the port can edit every site.
HAXCMS_EMBEDDED=1is for hosting haxcms-nodejs inside another runtime, such as haxcms-browser, which runs it in a browser Worker.src/app.jsbuilds the Express app and every route as usual but creates no HTTP server, never listens and starts no background timers. The host waits for the exportedappReadypromise and then passes requests to the exportedapp. Unset, nothing changes.
On first start, if the config directory (_config/ next to your sites, or
~/.haxcmsconfig) has no .user file, an admin user is created with a
random password. Only the scrypt hash is stored in .user; the plaintext is
written once to .initial-admin-password in the same config directory with
mode 0600, and the log shows only that file's path. The password is also
echoed to the terminal when stderr is an interactive TTY, but never to piped
or captured logs (Docker, systemd, CI). Log in, change the password, then
delete .initial-admin-password. When HAXCMS_RUNTIME_USERNAME /
HAXCMS_RUNTIME_PASSWORD are supplied (see below) those credentials are used
instead and no password file is written.
The image runs as the non-root node user and declares two volumes:
/app/_sites (site content) and /home/node/.haxcmsconfig (keys, salt,
hashed admin user, API keys). Mount both to persist data and secrets across
container re-creation, e.g.
docker run -p 3000:3000 \
-v haxcms-sites:/app/_sites -v haxcms-config:/home/node/.haxcmsconfig \
-e HAXCMS_RUNTIME_USERNAME=admin -e HAXCMS_RUNTIME_PASSWORD='<strong secret>' \
haxcms-nodejsWithout runtime credentials, read the seeded password with
docker exec <container> cat /home/node/.haxcmsconfig/.initial-admin-password.
Run endpoint conformance checks against src/openapi/site-spec.yaml:
npm run test:api-conformanceThe runner creates an isolated runtime workspace, then bootstraps a real site via API before endpoint checks run.
- The first bootstrap step calls
createSiteand generates a runtime site name:haxcms-test-harness-{timestampStartOfTest}
- All conformance calls then run against that real site path.
- Optional runtime login override values:
HAXCMS_TEST_USERNAMEHAXCMS_TEST_PASSWORD
Runtime credential overrides are also supported in-process via globals:
globalThis.HAXCMS_RUNTIME_CREDENTIALS = { username, password }globalThis.HAXCMS_RUNTIME_USERNAMEglobalThis.HAXCMS_RUNTIME_PASSWORD
When no globalThis override is set, the same HAXCMS_RUNTIME_USERNAME /
HAXCMS_RUNTIME_PASSWORD values are also read from process.env, so they can
be supplied as plain environment variables (e.g. Replit Secrets, Docker/host
env vars) instead of JS globals. globalThis values always take precedence
over the environment when both are present.
Current automated test coverage in this repository is the API conformance suite:
- Suite file:
test/api-conformance/site-spec.conformance.test.cjs - Script:
npm run test:api-conformance - Additional test scripts/suites are not currently wired in
package.json
The suite currently validates:
- Discovery/spec endpoints:
getSiteApiDiscovery,getSiteOpenApi,getSiteOpenApiJson,getSiteOpenApiYaml,getApiCatalog
- Site/content graph endpoints:
getSiteSummary,listEntityDescriptors,listSchemas,listItems,getItemByIdOrSlug,listContent,getContentByIdOrSlug,listTags,searchContent
- Component and metadata endpoints:
listCustomElements,getCustomElementByName,listBlocks,getBlockByName,getBlockUsage,listRegions,getRegionByName
- Theme/report/view/analytics endpoints:
listThemes,getActiveTheme,getThemeByName,listReports,getReportByName,getAnalyticsCapabilities,listViews,getViewById,getViewResults,listDisplaysAlias,getDisplayResultsAlias
- Secured file and revision endpoints:
listFiles,createFile,getFileByUuid,updateFileByUuid,replaceFileContent,deleteFileByUuid,listItemRevisions
Behavior coverage in the same suite includes:
- OpenAPI response/schema conformance checks
- Auth matrix checks for secured routes (no auth, bearer-only, invalid site token, valid site token)
- Boundary/error checks (missing required params, invalid ids/slugs, pagination/query bounds)
- Representation/header checks (
json,yaml,xml,md,htmlwhere supported) - End-to-end file lifecycle checks (create → list/find → get → update → delete)
Temporary known skip in the suite:
getApiCatalog returns linkset payload- Reason: runtime
/.well-known/api-catalogfixture behavior is still being finalized
- Reason: runtime
The critical write paths (the outline designer's bulk save PATCH /x/api/v1/site/outline, page content save, page create/delete, site settings save, file upload) are tested with faults injected at the filesystem boundary: fs-extra methods are mocked with node:test mocks so a write, copy or move throws ENOSPC, EACCES or EXDEV, or writes half a file and then fails. Malformed outline payloads (not an array, partial outline, missing ids, duplicate ids, missing parent, parent cycles) are covered too. No production code seam is used.
test/unit/fault-injection-save-outline.test.cjs: the saveOutline handler against a real site on disktest/unit/fault-injection-critical-writes-http.test.cjs: the real server in-process, over HTTP
Both run in npm test (blocking). To run only these:
node --test test/unit/fault-injection-*.test.cjsThe invariants they protect, for every fault:
- the client gets a non-2xx response with the OpenAPI
ApiErrorenvelope ({ status, data: { message } }) the UI can show - what was on disk before (
site.json, the page file) is unchanged, and nothing is left on disk thatsite.jsondoes not list - the server keeps answering requests
The write invariants behind them, kept the same in haxcms-php:
- every
site.jsonwrite is atomic: a temp file in the same directory is written, flushed and renamed over it (JSONOutlineSchema.writeFileAtomic), so a failed write leaves the previoussite.jsonas it was - an outline that cannot be encoded as JSON is an error, never a silent no-op:
JSONOutlineSchema.save()throws andsite.jsonis left as it was - a
site.jsonthat does not parse to an outline is refused on load, never treated as an empty outline that a save could write over it - an invalid outline payload (items that are not objects, an item without an id, a new page id sent twice, a parent cycle) is rejected with a 400 before anything is written
- a page folder exists only for a page
site.jsonlists: a request that created page folders removes them again when thesite.jsonwrite that would list them fails - an error thrown inside any API route answers the 500
ApiErrorenvelope (src/lib/routeHandlerError.js); it never leaves the request hanging or stops the server
saveOutline is checkpointed, not atomic as a whole: the new structure is written to site.json once after the structure pass, so a failure in the later content or delete phase leaves that structure saved.
Each scenario has an id (FI-OUT-*, FI-PAY-*, FI-NODE-*, FI-SITE-*, FI-UP-*, FI-HTTP-*) shared with haxcms-php, which mirrors these tests; keep both backends' scenarios in step. A scenario whose invariant does not hold yet is a test.todo whose name says what is wrong. When the product fix lands, turn it into a plain test in the same PR. To add a scenario, inject the fault with t.mock.method(fs, ...) (restore with t.mock.restoreAll() before checking the server still serves), give it the next free id, and add the same id to the PHP suite.
- MCP policy defaults are controlled via
_config/config.json. - New installs include:
deploymentProfile:single-site,self-hosted-multi-site, orhaxiam-managedmcp.enabled: global MCP togglemcp.readOnly: write-protection toggle for future MCP write tools
- Default behavior:
- MCP is disabled on every profile unless
mcp.enabledis explicitlytrue. - Once enabled, MCP stays read-only unless
mcp.readOnlyis explicitlyfalse.
- MCP is disabled on every profile unless
- Discord Channel - https://discord.gg/aCGxmRHEJP
- Unified issue queue - https://github.com/haxtheweb/issues/issues
- Using Merlin directly in any HAX spaces and type "Issue" to jump start a report!
- Try Hax: https://hax.cloud
- HAXCellence https://haxtheweb.org/what-is-hax
- Youtube channel - https://www.youtube.com/@haxtheweb

