[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
Documentationstart

start

Serve the production build of a project, with the options and secrets of the deployment it runs in.

ajs dms start serves the production frontend ajs dms build made from the project, in <project>/.dms-frontend or the one in --workspace. It computes the modules' public options again from the project's configuration and the variables it runs with, reads the secrets of its environment, and fetches nothing before the server is ready.

text
$ ajs dms start --help
Usage: ajs dms start [options]

Serve the production frontend ajs dms build made from the project. The modules'
public options are computed again from the project's configuration and the
current environment variables, so a deployment's variables need no rebuild.
Reads DMS_SESSION_SECRET and the server's secrets (DMS_HTML_RENDER_SECRET,
DMS_OAUTH_RELAY_SECRET) from its environment, and tells the backend once ready
which module versions it serves.

Options:
  -b, --backend-url <url>  Backend URL to serve; required (env:
                           DMS_API_BASE_URL)
  -p, --port <port>        Port to serve on (default: "3001", env: PORT)
  --project <dir>          The AntelopeJS project whose antelope.config.ts and
                           installed modules make the frontend (default: ".")
  -e, --env <environment>  The AntelopeJS environment whose configuration
                           applies, as ajs project start -e (default:
                           "production", env: ANTELOPEJS_LAUNCH_ENV)
  --workspace <dir>        Serve the build in this directory instead of
                           <project>/.dms-frontend; start writes nothing into it
                           (env: DMS_WORKSPACE_DIR)
  -h, --help               Show help for a command

A start

text
$ ajs dms start -b http://localhost:5050 -p 3005
ajs dms start  http://localhost:5050 · production · built 2 min ago
✔ Production server ready in 362ms

  ➜  Local:     http://localhost:3005/
  ➜  Network:   http://192.0.2.2:3005/
     Backend:   http://localhost:5050
     Workspace: ./.dms-frontend
     Secrets:   DMS_HTML_RENDER_SECRET, DMS_OAUTH_RELAY_SECRET from the environment
     Ctrl+C to stop

Routing: renderer files, then 21 module routes, then the backend proxies below, then the pages
  /api/**    -> backend (session), declared by antelopejs__dms-frontend-vue
  /dms/**    -> backend (session), declared by antelopejs__dms-frontend-vue
  /ai/**     -> backend (session), declared by @antelopejs/dms-assistant-frontend-vue
  /i18n/**   -> backend (none), declared by @antelopejs/dms-lang-frontend-vue
  /media/**  -> backend (session), declared by @antelopejs/dms-media-frontend-vue

The modules' public options

start evaluates antelope.config.ts again, with the variables of its own environment, and calls each module's frontendModule as build did. The options it computes replace the ones the build wrote, in the server and in every page it sends. A deployment that sets DMS_API_PUBLIC_BASE_URL, a Stripe key or any other variable an option reads needs no rebuild. Give the frontend the same values as the backend, for instance by referencing the backend's variables.

The server's secrets

The build holds no secret, so the server reads every secret from its environment.

VariableWhat it must equalUnset
DMS_SESSION_SECRET32 characters or more, the same across restartsstart refuses to run
DMS_HTML_RENDER_SECRETThe backend's htmlRender.serviceSecretE-mail renders are refused
DMS_OAUTH_RELAY_SECRETThe backend's OAuth relay secret, an HMAC-SHA256 of its JWT secretOAuth sign-in is refused by the backend
DMS_PRIVATE_OPTIONSAny other private option a module publishes, as JSON by module id, such as {"acme__shop-frontend-vue":{"apiKey":"…"}}The module's server routes get an empty value

The module ids are the keys of generated-server-options.json in the workspace, which lists every private option with its value emptied. start warns, before the server starts, about each one it runs without, naming the module and the option.

A build shipped with its project

--workspace <dir> serves the build that ajs dms build --workspace <dir> made, wherever it is, for instance in a container image. start writes nothing into it, so the directory and the image can be read-only.

With DMS_API_BASE_URL set in the environment, -b can be left out:

Terminal bash
ajs dms start --workspace .dms-frontend -p 3000

Telling the backend what it serves

Once the server is ready, start sends POST /dms/frontend/ready to the backend, with DMS_BOOTSTRAP_SECRET. The request carries the name and version of each module it serves, and its own version. Those are the modules the build holds, read from its registry.

The project's configuration, with the current variables, can give other modules, for example when a variable turns a module on or off. start then warns and names them. The server keeps serving the build's modules until you build again with those variables.

The backend compares the reported versions with the ones it runs, and logs a warning naming each module that differs. Deploy the frontend and the backend from the same commit to avoid it.

The server never waits for the answer. A backend that is asleep, starting (a 5xx) or out of reach gets the report again in the background. The first retry comes after 2 seconds, and each delay doubles, up to a minute, until the backend first answers. Any other answer, such as a refused credential, ends the retries.

Defaults that differ from dev

devstart
Address it binds to (HOST)127.0.0.10.0.0.0
Secure cookies (DMS_COOKIE_SECURE)OffOn
Builds of Vue and its libraries (NODE_ENV)DevelopmentProduction
Session secret (DMS_SESSION_SECRET)Generated once per workspace when unsetRequired, the same across restarts
Busy portMoves to the next free oneStops

start runs the server with NODE_ENV=production unless the environment, or the project's .env, sets another value. Vue, its server renderer and vue-i18n read it when the server loads them. Under any other value, pages render with their development builds, which are slower and print [Vue warn] messages. start warns about it before the server starts:

text
▲ NODE_ENV is development: the server renders with the development builds of Vue and its libraries
  → Unset it for start, or set it to production

Production cookies are Secure, so a browser sends them only over HTTPS. Put start behind a TLS-terminating reverse proxy, or set DMS_COOKIE_SECURE=false for a plain-HTTP test.

Errors

text
$ ajs dms start -b https://dms.example.com
✖ No production build to serve
  ./.dms-frontend has no built server or client.
  → Build it first: ajs dms build
text
$ ajs dms start -b http://localhost:5050 -p 3007
ajs dms start  http://localhost:5050 · production · built 3 min ago
✖ Port 3007 is already in use
  → Stop the process listening on it, or pass another port: -p <port>

Ctrl+C stops the server and exits with code 130:

text
■ Stopped the production server · ran 27.4s