Skip to content

Latest commit

 

History

History
124 lines (101 loc) · 4.76 KB

local-development.md

File metadata and controls

124 lines (101 loc) · 4.76 KB
type Guide
title Local development
description Clone, install, build and run the XYZ monorepo on a local machine, with a minimal workspace, a VS Code launch configuration and the first-run checks.
tags
deployment
setup
development
pnpm
varlock
status draft
resource ../../apps/xyz/server.js
sources
id resource
setup
../../SETUP.md
id resource x-xyz-revision
wiki
3fc379b7ada42dff57f19e9f28694868e5a17cac
id resource
package
../../package.json
id resource
workspace-yaml
../../pnpm-workspace.yaml
id resource
xyz-package
../../apps/xyz/package.json
id resource
varlock
../../varlock/README.md
id resource
acl
../../apps/xyz/mod/user/acl.js
id resource
devdb
../../packages/devdb/start.js

Local development

The repository is a pnpm workspace driven by Turborepo.1 This concept replaces SETUP.md.2

The monorepo concept lists its packages: the XYZ API and server (apps/xyz), the MAPP and MAPP.UI libraries, the auth and SAML apps, and the devdb and testhost packages for tests. SETUP.md listed four apps and omitted apps/auth.

Each app has a README with app-specific usage. In the browser, without a local install, see Codespaces.

Prerequisites

  • git and Node.js 22 or later. CI runs Node 22; there is no engines field.
  • pnpm 11. The root packageManager pins pnpm@11.3.0.3

Clone, install, build

git clone https://github.com/GEOLYTIX/xyz.git
cd xyz
pnpm install
pnpm build

The MAPP and MAPP.UI bundles (public/js/lib, public/css/mapp.css, public/css/ui.css) are gitignored on the development branches, so a branch checkout must be built before the server can serve the default view. A checkout of main or a release tag, eg. --branch v5.0.7, already contains them. See release builds.

Environment

The server reads environment variables. The minimal configuration is the repository workspace with one OSM tile layer:

WORKSPACE=file:./public/workspace.json

file: paths resolve from XYZ_CWD, which defaults to the repository root, so file:/public/workspace.json resolves to the same file.

apps/xyz/server.js does not load .env itself; dotenv is no longer imported since v5.4 An .env in the repository root is read when the process runs through Varlock, which the dev scripts do (varlock run -- node --inspect server.js, with loadPath set to the root).5 Start from the examples in varlock/:

cp varlock/vanilla.env .env
cp varlock/vanilla.env.schema .env.schema

Declare new variables in .env.schema, and mark secrets sensitive so Varlock redacts them. pnpm exec varlock load --compact validates the files. See varlock/README.md for secret managers.6 Commit neither .env* nor .varlock.blob.

Variables often set locally: TITLE, SECRET or SECRET_KEY, DIR, PRIVATE/PUBLIC, DBS_*, CUSTOM_TEMPLATES, TRANSPORT_*, SAML_* and TRUSTED_RETURN_HOSTS. Look each up with pnpm knowledge:find <name>.

Databases and authentication

A database is only needed when the workspace, templates or ACL use one. Set a DBS_* connection per database. The ACL variables PRIVATE and PUBLIC take a connection string and the ACL table, separated by |; the schema defaults to public:

DBS_MAIN=postgres://user:password@localhost:5432/my_database
PRIVATE=postgres://user:password@localhost:5432/my_database|acl_schema.acl_table

SETUP.md showed PRIVATE=localhost:5432|user:password|acl_table, which the ACL module does not parse.7 For a local PostGIS database without an install, run the devdb with pnpm --filter=@geolytix/xyz-devdb start (port 5433, or DEVDB_PORT); it prints a DBS_DEV connection string.8 For a hosted database, see Neon.

A PRIVATE SAML instance sets AUTH_PATH=/saml; SAML_LOGIN was removed in v5.0.0. See apps/saml/README.md.

Run the server as described in running locally. For tests see TESTING.md, for the workflow and Biome DEVELOPING.md.

Footnotes

  1. pnpm-workspace.yaml packages list. ↩

  2. SETUP.md, folded into this concept. ↩

  3. Root package.json packageManager and scripts. ↩

  4. Wiki Getting-started page. ↩

  5. apps/xyz/package.json dev script and varlock.loadPath. ↩

  6. varlock/README.md. ↩

  7. apps/xyz/mod/user/acl.js splits PRIVATE or PUBLIC on |. ↩

  8. packages/devdb/start.js; the root has no devdb script. ↩