Enjazy 2 self-hosted server 2.0.0

Requirements
- Node.js >=24.13.0 <25

Run the server
The production bundle is already built in this archive:

  node apps/server/dist/server.mjs

The server listens on the host and port named by ENJAZY_HOST / ENJAZY_PORT (defaults 0.0.0.0 / 8787),
serves the API, the server-rendered pages, the admin console (/console/), the same-origin web app and
the documentation (/docs/), and stores its data under ./data by default.

Docker alternative
  docker build -f apps/server/Dockerfile .
  docker run --rm -p 8787:8787 <image>

Environment variables
(every variable the server reads; the full guide is /docs/self-host/ on the running server)
  `ENJAZY_HOST` (default: `0.0.0.0`) — The interface the HTTP server binds to.
  `ENJAZY_PORT` (default: `8787`) — The TCP port the HTTP server listens on.
  `ENJAZY_AUTH` (default: `none`) — Auth mode: `none`, `api-key` or `accounts` (truthy 1.x values map to `accounts`).
  `ENJAZY_API_KEYS` (default: (empty — no API keys)) — A comma-separated list of API keys for single-tenant `api-key` mode.
  `ENJAZY_API_KEYS_SYNC` (default: `false`) — In `api-key` mode, `true` puts the API-key guard on the sync channel `/api/sync/*` too (no or wrong key answers `401 unauthorized`). Off keeps sync public so 1.x apps keep syncing, and the server logs the `api_key_sync_public` boot warning. Turn it on once every app that syncs with the server sends a key.
  `ENJAZY_DB_DRIVER` (default: `sqlite`) — The single-tenant store driver: `sqlite` or `mysql`.
  `ENJAZY_DB` (default: `./data/enjazy-server.db`) — The single-tenant SQLite database path.
  `ENJAZY_MYSQL_HOST` (default: `127.0.0.1`) — The MySQL host when `ENJAZY_DB_DRIVER=mysql`.
  `ENJAZY_MYSQL_PORT` (default: `3306`) — The MySQL port.
  `ENJAZY_MYSQL_USER` (default: `enjazy_user`) — The MySQL user.
  `ENJAZY_MYSQL_PASSWORD` (default: (empty)) — The MySQL password.
  `ENJAZY_MYSQL_PASSWORD_FILE` (default: unset) — A file whose content (without its final line ending) is the MySQL password; `ENJAZY_MYSQL_PASSWORD` wins when both are set.
  `ENJAZY_MYSQL_DATABASE` (default: `enjazy_db`) — The MySQL database name.
  `ENJAZY_MYSQL_TLS_CA` (default: unset) — A PEM CA used for the MySQL TLS connection.
  `ENJAZY_MYSQL_TLS_REJECT_UNAUTHORIZED` (default: `true`) — Whether to verify the MySQL server certificate.
  `ENJAZY_AUTH_DB` (default: `./data/auth.db`) — The auth/control database path in accounts mode.
  `ENJAZY_USERS_DIR` (default: `./data/users`) — The per-user store directory in accounts mode.
  `ENJAZY_ISSUER` (default: unset) — The public issuer URL (`{issuer}`) used in links and e-mails.
  `ENJAZY_SITE_ORIGIN` (default: unset) — Online only: the public website and `/console` origin. Defaults to `http://localhost:<port>` on Online; its app/issuer defaults to `the.` plus this hostname, with the same scheme and port. Ignored by the self-hosted composition root.
  `ENJAZY_CORS` (default: `*`) — The CORS allow-list; unset, blank or `*` reflects any origin.
  `ENJAZY_TLS_CERT` (default: unset) — A TLS certificate file to enable the built-in HTTPS listener.
  `ENJAZY_TLS_KEY` (default: unset) — The TLS key file for the built-in HTTPS listener.
  `ENJAZY_HTTP_PORT` (default: unset) — An optional cleartext companion port alongside built-in TLS.
  `ENJAZY_TRUST_PROXY` (default: `loopback`) — Which proxies' `X-Forwarded-*` headers are trusted: `none`, `loopback`, or a list of addresses.
  `ENJAZY_ADMIN_USER` (default: unset) — The first-run admin username.
  `ENJAZY_ADMIN_EMAIL` (default: unset) — The first-run admin e-mail.
  `ENJAZY_ADMIN_PASSWORD` (default: unset) — The first-run admin password.
  `ENJAZY_ADMIN_PASSWORD_FILE` (default: unset) — A file whose content (without its final line ending) is the first-run admin password; `ENJAZY_ADMIN_PASSWORD` wins when both are set.
  `ENJAZY_SIGNUPS` (default: `false`) — Whether self-service sign-up is enabled.
  `ENJAZY_SETUP_SKIP_VALIDATION` (default: `false`) — Skips the first-run public-URL validation.
  `ENJAZY_PLAN_GATES` (default: `off`) — Plan gates: `off`, `legacy` or `all`.
  `ENJAZY_SMTP_URL` (default: unset) — A full SMTP connection URL.
  `ENJAZY_SMTP_HOST` (default: unset) — The SMTP host (used when `ENJAZY_SMTP_URL` is unset).
  `ENJAZY_SMTP_PORT` (default: `587`) — The SMTP port.
  `ENJAZY_SMTP_USER` (default: unset) — The SMTP user name.
  `ENJAZY_SMTP_PASSWORD` (default: unset) — The SMTP password.
  `ENJAZY_SMTP_PASSWORD_FILE` (default: unset) — A file whose content (without its final line ending) is the SMTP password; `ENJAZY_SMTP_PASSWORD` wins when both are set. The setup wizard writes this one.
  `ENJAZY_SMTP_SECURE` (default: `false`) — Whether SMTP uses a secure connection.
  `ENJAZY_MAIL_FROM` (default: unset) — The sender address; unset derives `no-reply@<public host>`.
  `ENJAZY_MAIL_FROM_NAME` (default: unset) — The sender name; unset uses the public host on a self-hosted server.
  `ENJAZY_MAIL_TRANSPORT` (default: `smtp` when `ENJAZY_SMTP_URL` or `ENJAZY_SMTP_HOST` is set; otherwise `file` in development and `none` in production) — The mail transport override: `smtp`, `file` or `none`.
  `ENJAZY_SUPPORT_EMAIL` (default: unset) — The support e-mail published in the public config.
  `ENJAZY_DEVICE_LICENCE_SALES` (default: `false`) — Enjazy Online only: `true` sells the lifetime Desktop + Mobile licence at Checkout. Off by default (the Desktop and Mobile apps are free; Checkout refuses `device`). A self-hosted server ignores it.
  `ENJAZY_SALES_EMAIL` (default: `info@roaa.tech`) — Enjazy Online only: the inbox that receives the Business "Contact us" requests from the website's pricing page (one e-mail per request, through the mail outbox). One address. A self-hosted server has no such form.
  `ENJAZY_WEB_APP_ORIGIN` (default: unset) — The public origin used in copied links behind a rewriting proxy.
  `ENJAZY_PRIVACY_URL` (default: unset) — The target of `/privacy`; unset renders the family 404.
  `ENJAZY_TERMS_URL` (default: unset) — The target of `/terms`; unset renders the family 404.
  `ENJAZY_HELP_URL` (default: unset) — The target of `/help`; unset renders the family 404.
  `ENJAZY_STATUS_URL` (default: unset) — The status link published in the public config.
  `ENJAZY_LOG_LEVEL` (default: `info`) — The pino log level: `fatal`, `error`, `warn`, `info`, `debug`, `trace` or `silent`.
  `ENJAZY_SAAS_URL` (default: unset) — The Enjazy Online URL used by clients, and where a Free server buys Pro (unset: `https://the.enjazy.app`). A server key names its own issuer, so a key does not need it.
  `ENJAZY_LICENSE_KEY` (default: unset) — A signed server key (`esk1.…`) from Enjazy Online. It wins over a key installed on the admin Licence page, which then shows it read-only. Old `esl_` keys are not accepted.
  `ENJAZY_LICENSE_OWNER_TOKEN` (default: unset) — Retired: ignored. When it is set the server logs `licence.owner_token_ignored` at boot and the Licence page says so. Use a server key.
  `ENJAZY_LICENCE_ROOT_KEY_FILE` (default: unset) — Enjazy Online only: the licence root private key file (Ed25519 JWK) that signs server keys and server licences. Keep it secret and outside the repository. A release build without it cannot create server keys.
  `ENJAZY_PLANS_DB` (default: `./data/saas/plans.db`) — The plans catalogue database path.
  `ENJAZY_SERVER_LICENSES_DB` (default: `./data/saas/server-licenses.db`) — The server licence keys database path.
  `ENJAZY_CLIENT_LICENSES_DB` (default: `./data/saas/client-licenses.db`) — The client licence keys database path.
  `ENJAZY_PLAN_SUBSCRIPTIONS_DB` (default: `./data/saas/plan-subscriptions.db`) — The subscriptions database path.
  `ENJAZY_TRIAL_DAYS` (default: `14`) — Enjazy Online only: the days of the free Business trial each new account gets (counted only while it is the plan in force, after the sign-up offer); `0` turns it off. A self-hosted server has no trial.
  `ENJAZY_SIGNUP_PROMO_MONTHS` (default: `4`) — Enjazy Online only: the sign-up offer of each new account in months of 30 days (counted only while it is the plan in force, before the trial); `0` turns it off. A self-hosted server has no offer.
  `ENJAZY_REQUIRE_VERIFIED_EMAIL` (default: `false` (Enjazy Online: `true`)) — When `true`, an account must confirm its e-mail address before it can use a paid plan or share lists. Turn it on only when mail delivery works (`ENJAZY_SMTP_URL` or `ENJAZY_SMTP_HOST`), so people get the confirmation link. Administrators can mark an address verified in the console.
  `ENJAZY_REFERRALS` (default: `true`) — Enjazy Online only: invite codes and their rewards; `false` turns the program off. A self-hosted server has no invite program.
  `ENJAZY_STRIPE_SECRET_KEY_FILE` (default: unset) — Enjazy Online only: the file holding the Stripe secret key. With the two settings below it turns billing on; a self-hosted server ignores it.
  `ENJAZY_STRIPE_WEBHOOK_SECRET_FILE` (default: unset) — Enjazy Online only: the file holding the Stripe webhook signing secret (`whsec_…`).
  `ENJAZY_STRIPE_PRICES` (default: unset) — Enjazy Online only: the Stripe price ids, `plan:interval=price_id`, comma-separated (plans `pro`, `team`, `business`; intervals `month`, `year`).
  `ENJAZY_STRIPE_AUTOMATIC_TAX` (default: `false`) — Enjazy Online only: Stripe Tax calculates tax at Checkout.
  `ENJAZY_STRIPE_SUCCESS_URL` (default: `<web app>/settings/plan`) — Enjazy Online only: where Stripe Checkout returns after a payment.
  `ENJAZY_STRIPE_CANCEL_URL` (default: `<web app>/settings/plan`) — Enjazy Online only: where Checkout returns when abandoned, and where the billing portal returns.
  `ENJAZY_WEBHOOKS` (default: (empty — no webhooks)) — The operator-configured webhook URLs.
  `ENJAZY_WEBHOOK_SECRET` (default: unset) — The HMAC secret for webhook signing.
  `ENJAZY_WEBHOOK_POLL_MS` (default: `1000`) — The webhook poll interval in milliseconds.
  `ENJAZY_TEST_MYSQL_URL` (default: unset) — A MySQL URL used by tests only.
  `ENJAZY_AI_PROVIDER` (default: unset) — The AI provider type: `openai` (OpenAI-compatible) or `anthropic` (Anthropic-compatible). See [AI assistant](#ai-assistant-bring-your-own-key).
  `ENJAZY_AI_BASE_URL` (default: unset) — The provider's base URL, for example `https://api.deepseek.com`.
  `ENJAZY_AI_MODEL` (default: unset) — The provider's model id, for example `deepseek-chat`.
  `ENJAZY_AI_KEY_FILE` (default: unset) — A file whose whole content (trimmed) is the provider API key. The key itself is never an environment value.
  `ENJAZY_AI_TIMEOUT_MS` (default: `30000`) — The time limit of one provider request in milliseconds, kept within 1000–120000.
  `ENJAZY_AI_MAX_TOKENS` (default: `1024`) — The most tokens the provider may write in one answer, kept within 64–8192.
  `ENJAZY_PUSH_CONTACT` (default: unset (falls back to `mailto:` + `ENJAZY_SUPPORT_EMAIL`, then an `https://` `ENJAZY_ISSUER`)) — The operator contact sent to browser push services with every web push reminder (VAPID `sub`): `mailto:you@example.com` or an `https://` URL.
  `ENJAZY_PUSH_VAPID_FILE` (default: `push-vapid.json` in the data directory) — The VAPID key file of web push reminders. Created at first start when missing; keep it with your backups.
  `ENJAZY_ENV` (default: unset) — Set to `production` (or set `NODE_ENV=production`) to enable production behaviour.
  `NODE_ENV` (default: unset) — Set to `production` to enable the same production behaviour as `ENJAZY_ENV=production`.
  `ENJAZY_STRIPE_SERVER_PRICES` (default: unset) — Enjazy Online only: Server Pro prices, `month=price_…`, `year=price_…` (recurring) and `lifetime=price_…` (paid once, the lifetime server licence), comma-separated and distinct from the Online prices. Unset disables server purchases. Use Stripe test-mode prices until the owner configures the live account.
