testing/cross_backend/default_backend_configs.ts

Family-shared BackendConfig builders for cross-process test backends.

Two consumer-facing factories — {@link make_default_ts_backend_config} and {@link make_default_rust_backend_config} — own the common shape for the JS-runtime (Deno/Node on V8) and Rust families respectively. Per-backend factories in consumer projects compose a small declaration against one of these and add consumer-specific env vars via extra_env.

Defaults baked in by family:

  • TS'memory://' PGlite, 30s startup window. Its shape notes (ts_default_shape_notes) record trusted_proxy: false / login_rate_limit: false — the TS canonical path leaves those limiters null in test mode.
  • Rust — caller-supplied real Postgres URL (PGlite isn't reachable from tokio-postgres), 120s startup window (cargo first-build cost), the FUZ_TESTING_RESET_DB_ON_STARTUP=true self-wipe gate, and shape notes (rust_default_shape_notes) recording trusted_proxy: true + login_rate_limit: true.

Both builders default port_env_var to 'PORT'. Consumers whose binary reads a different name (e.g. zzz's ZZZ_PORT) override.

Common across both families: /api/rpc, /api/ws, /health, /api/account/bootstrap, cookie_name: 'fuz_session', the standard bootstrap block keyed off default_test_* constants. Builders call build_test_backend_paths(name) internally when the optional paths is omitted.

view source

Declarations
#

9 declarations

LOGIN_RATE_LIMIT_ENABLED_ENV
#

testing/cross_backend/default_backend_configs.ts view source

"FUZ_LOGIN_RATE_LIMIT_ENABLED" import {LOGIN_RATE_LIMIT_ENABLED_ENV} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Env var both spine binaries read to enable their login rate limiters ('true' on / unset off). The cross-language contract for the login-security cross project: the TS binary reads it via runtime.env_get (a test-only flag, not in BaseServerEnv); the Rust testing_spine_stub reads it via std::env::var — so one backend-config option drives both impls. Shared home here because both ts_spine_backend_config and rust_spine_stub_backend_config already import this module. (The spawned TS binary re-declares the literal locally — it can't import this module, which transitively pulls vitest — mirroring how testing_spine_server_node.ts re-declares TS_SPINE_DIR_ENV.)

make_default_rust_backend_config
#

testing/cross_backend/default_backend_configs.ts view source

(opts: MakeDefaultRustBackendConfigOptions): BackendConfig import {make_default_rust_backend_config} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Shared builder for Rust-family backends. Owns the common env baseline (RUST_LOG, HOST, port, real Postgres, cookie keys, bootstrap token path, the FUZ_TESTING_RESET_DB_ON_STARTUP=true self-wipe gate) plus the 120s startup window for cargo's first-run build cost.

opts

returns

BackendConfig

make_default_ts_backend_config
#

testing/cross_backend/default_backend_configs.ts view source

(opts: MakeDefaultTsBackendConfigOptions): BackendConfig import {make_default_ts_backend_config} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Shared builder for TS-family backends (Deno + Node). Owns the common env baseline (NODE_ENV, HOST, PORT, in-memory PGlite, cookie keys, bootstrap token path) so per-backend factories only declare what genuinely differs.

opts

returns

BackendConfig

MakeDefaultRustBackendConfigOptions
#

testing/cross_backend/default_backend_configs.ts view source

MakeDefaultRustBackendConfigOptions import type {MakeDefaultRustBackendConfigOptions} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

name

Diagnostic label; also used as the tmpdir prefix when paths is omitted.

type string

readonly

port

TCP port the binary listens on.

type number

readonly

start_command

argv passed to the spawn (first entry is the binary).

type ReadonlyArray<string>

readonly

database_url

Required — Rust needs real Postgres (PGlite isn't reachable from tokio-postgres). Consumers typically supply 'postgres://localhost/{repo}_test_{name}'.

type string

readonly

extra_env?

Merged on top of the generic env baseline; later keys win.

type Readonly<Record<string, string>>

readonly

capabilities?

type BackendCapabilities

readonly

paths?

Pre-computed paths; defaults to build_test_backend_paths(name).

type TestBackendPaths

readonly

bootstrap_overrides?

Override individual bootstrap fields (username/password/token).

type Partial<BackendBootstrapConfig>

readonly

port_env_var?

Env-var name the binary reads for its port. Defaults to 'PORT'. Consumers whose binary reads a different name (e.g. 'ZZZ_PORT') override.

type string

readonly

rust_log?

Initial value for RUST_LOG. Defaults to 'info'. Consumers pass their binary-specific module filter (e.g. 'info,zzz_server=info,testing_zzz_server=info').

type string

readonly

cookie_name?

Session cookie name the binary uses. Defaults to 'fuz_session'. Must match the consumer's session config (see the TS builder's note).

type string

readonly

MakeDefaultTsBackendConfigOptions
#

testing/cross_backend/default_backend_configs.ts view source

MakeDefaultTsBackendConfigOptions import type {MakeDefaultTsBackendConfigOptions} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

name

Diagnostic label; also used as the tmpdir prefix when paths is omitted.

type string

readonly

port

TCP port the binary listens on.

type number

readonly

start_command

argv passed to the spawn (first entry is the binary).

type ReadonlyArray<string>

readonly

database_url?

Defaults to 'memory://' (in-memory PGlite).

type string

readonly

extra_env?

Merged on top of the generic env baseline; later keys win.

type Readonly<Record<string, string>>

readonly

capabilities?

type BackendCapabilities

readonly

paths?

Pre-computed paths; defaults to build_test_backend_paths(name).

type TestBackendPaths

readonly

bootstrap_overrides?

Override individual bootstrap fields (username/password/token).

type Partial<BackendBootstrapConfig>

readonly

port_env_var?

Env-var name the binary reads for its port. Defaults to 'PORT'. Consumers whose binary reads a different name (e.g. 'ZZZ_PORT') override.

type string

readonly

cookie_name?

Session cookie name the binary's create_session_config uses. Defaults to 'fuz_session'. Must match the consumer's session config — the harness threads the _testing_reset-returned keeper cookie into its jar under this name, so a mismatch surfaces as 401s on the create_account path (e.g. fuz_forge uses 'fuz_forge_session').

type string

readonly

rust_default_capabilities
#

rust_default_shape_notes
#

testing/cross_backend/default_backend_configs.ts view source

BackendShapeNotes import {rust_default_shape_notes} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Shape notes for Rust-family backends — wiring facts, not gating flags. Adds trusted_proxy: true (the Rust spine's client-IP middleware is always wired; the env-gate only chooses XFF vs the TCP peer IP) and login_rate_limit: true (env-gated bucket on /login + /password). Documentation only — see BackendShapeNotes.

ts_default_capabilities
#

ts_default_shape_notes
#

testing/cross_backend/default_backend_configs.ts view source

BackendShapeNotes import {ts_default_shape_notes} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Shape notes for TS-family backends — wiring facts, not gating flags. trusted_proxy: false (the test binary doesn't enable proxy parsing) and login_rate_limit: false (the TS canonical path leaves the limiter null in test mode); bearer auth is always wired. Documentation only — see BackendShapeNotes.

Depends on
#

Imported by
#