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

dev

Run the dashboard with hot reload against a backend on the same machine, and what each kind of edit reloads.

ajs dms dev serves the dashboard with hot reload. It reads the frontend modules from the AntelopeJS project, as build does, and serves them in place from their sources, so the backend runs on the same machine.

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

Run the dev server with hot reload. It reads the frontend modules from the
AntelopeJS project as build does, each module's frontendModule called with dev:
true, and serves them in place from their sources. The backend, on this machine,
gives the secrets it holds and says when the module store changes its modules.

Options:
  -b, --backend-url <url>      Backend URL; when omitted, discovered from the
                               enclosing antelope project's .antelope/dev.json
                               (env: DMS_API_BASE_URL)
  --project <dir>              The AntelopeJS project the modules are read from
                               (default: the discovered backend's, else the
                               current directory)
  -e, --env <environment>      The AntelopeJS environment the backend runs, as
                               ajs project dev -e (default: the base
                               configuration) (env: ANTELOPEJS_LAUNCH_ENV)
  -p, --port <port>            Port to serve on (default: "3001", env: PORT)
  -f, --force                  Reinstall the workspace dependencies
  --offline                    Reuse the last cached manifest instead of
                               fetching it (env: DMS_OFFLINE)
  --bootstrap-secret <secret>  Credential for the backend's layer endpoints;
                               prefer the variable, a command line is visible to
                               other processes. Discovered from
                               .antelope/dms-dev.json for the project's own
                               backend (env: DMS_BOOTSTRAP_SECRET)
  -h, --help                   Show help for a command

Where the modules come from

dev evaluates the project's antelope.config.ts for the environment -e names, as ajs project dev does. Without -e, it uses the base configuration. It then calls the frontendModule each module declares with dev: true, so it gets the same modules and options a build computes. A mistake in a module's frontendModule therefore shows in dev, not first in production. The project is the discovered backend's, or the one --project names.

The backend still supplies what only it knows:

  • The secrets it holds. They fill the private options each module declares, as start fills them from its environment.
  • The development origins it serves. dev applies them to the options the same way the backend applies them to its own manifest.
  • Its set of frontend modules. dev follows that set and rebuilds when the module store changes it.

When the project and the backend disagree on a module, dev serves the project's version, which is what a build would serve, and prints a warning that names the module.

Finding the backend

Without -b or DMS_API_BASE_URL, dev walks up from the current directory to the first .antelope/dev.json, the file a running ajs project dev writes. It checks that the process that wrote it is still alive, then reads the API server's address from it. It stops at the first file it finds, so it never attaches to a parent project's backend.

text
$ ajs dms dev
✖ No backend URL provided and no running antelope project found
  Searched for .antelope/dev.json from the current directory upward.
  → Run this command inside an antelope project started with 'ajs project dev'
  → Or pass the backend explicitly with -b <url> (env: DMS_API_BASE_URL)

The bootstrap credential comes the same way. When the backend it calls is the one .antelope/dev.json names, dev reads the credential the development backend publishes in .antelope/dms-dev.json. A credential found this way is never sent to any other backend. An explicit --bootstrap-secret or DMS_BOOTSTRAP_SECRET always wins.

Warning

A discovered backend keys the workspace on the project directory, not on the URL, so it survives the backend landing on another port. ajs dms dev -b <url> keys it on the URL instead, and shares it with prepare -b <url>. build and start use neither workspace. They work in <project>/.dms-frontend, or in the directory --workspace names. See Workspaces and cache.

The port

dev reserves its port before it asks the backend for the manifest, and sends the resulting address to the development backend, which serves a matching client URL and allows that origin. When the port is busy, dev moves to the next free one and prints Port 3001 is busy, using 3002. -p 0 asks for any free port.

The server listens on 127.0.0.1 unless HOST says otherwise. HOST=0.0.0.0 opens it to the network.

Sessions and secrets

dev generates a random session secret when DMS_SESSION_SECRET is not set at all, and keeps it in the workspace's .session-secret file, readable by you alone, so a restart keeps everyone signed in. ajs dms clean deletes it with the workspace. A value you set is kept, but an empty value or one shorter than 32 characters is refused. Cookies are not Secure unless DMS_COOKIE_SECURE says so, since the development server runs over HTTP.

The e-mail render and OAuth relay secrets come from the manifest the backend serves, for the modules that declare them in their private options. The Secrets line of the ready block says where each one came from, never its value. Configuration says which value wins when you also set the variable.

What reloads, and how

dev copies each module into the workspace and watches its sources, mirroring every edit.

You changeWhat happens
A .vue file, a composable, a styleVite hot module replacement
A component a layer registersThe next server render sets every module up again, into empty registries, so it uses the edited component without a restart
i18n/locales/*.jsondev regenerates the merged catalogs, and the open page applies them in place. Adding or removing a locale reloads the page. dev reports a file that does not parse, or that holds a message vue-i18n cannot compile, with its key and fix. The page keeps the previous catalogs until you fix it. See Translations.
app/app.config.tsThe next server render uses it. The open page updates useDmsAppConfig() and Nuxt UI's config in place.
A file under public/Served, or no longer served, at once
Adding or removing dms.frontend.ts or app/config/shortcuts-registry.tsThe module loader or the aggregated shortcuts are regenerated, and the page reloads
dms.frontend.build.tsVite restarts
dms.server.ts or a file it importsThe next request uses the edited handler
An e-mail templateThe e-mail bundle rebuilds in a separate, low-priority process. A render waits for a build in progress.
A layer directory added to or removed from layers/The dev server says it needs a restart, because Vite reads layer aliases and auto-imported directories at startup only

The backend starts serving another set of frontend modules when someone installs or removes a module from the Modules page. The module store writes that change to antelope.config.ts. dev then stops the server, reads the project again, rebuilds the workspace and starts again:

text
ℹ Frontend modules changed on the backend: rebuilding the workspace

When the backend is down

dev falls back to the last manifest it cached for the workspace, with a warning, and API calls fail until the backend is back. --offline uses the cache without trying the backend. A refused credential never falls back, because the cache can hold private options from an earlier authorized run.

Seeing who answers a path

In development, every answer carries an x-dms-route-owner header. Its value is renderer, module:<id>, backend:<pattern>, page or not-found.

text
$ curl -sI http://localhost:3005/api/dms/nothing | grep x-dms-route-owner
x-dms-route-owner: backend:/api/**

See Routing and the backend proxy for the order the server follows.

Stopping

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

text
■ Stopped the dev server · ran 3.2s