testing/cross_backend/default_backend_configs.ts

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

Two consumer-facing factories — make_default_ts_backend_config and make_default_rust_backend_config — own the common shape for the JS-runtime (Node, Bun) 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://' (in-memory pglet), 30s startup window.
  • Rust — caller-supplied real Postgres URL (an in-process WASM database isn't reachable from tokio-postgres), 120s startup window (cargo first-build cost), and the FUZ_TESTING_RESET_DB_ON_STARTUP=true self-wipe gate.

Both builders default port_env_var to 'PORT'. Consumers whose binary reads a different name (e.g. zzz's ZZZ_PORT) override. Both bind HOST to DEFAULT_TEST_BACKEND_HOST (127.0.0.1), and, given the name of the binary's daemon-token directory env var (daemon_token_dir_env), set it to the {dir} whose {dir}/run/daemon_token is the bootstrap's daemon_token_path (to_daemon_token_dir).

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 default_test_backend_paths(name) (a repo-namespaced tmpdir) internally when the optional paths is omitted.

view source

Declarations
#

12 declarations

action_rate_limit_env
#

testing/cross_backend/default_backend_configs.ts view source

(options: ActionRateLimitEnvOptions): Record<string, string> import {action_rate_limit_env} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

The extra_env entries carrying the action rate-limit toggles, shared by the TS and Rust backend configs so one option pair drives both impls. action_rate_limit_max_attempts is passed through even without the enable flag, so the binary refuses the combination instead of the harness hiding it.

options

returns

Record<string, string>

ActionRateLimitEnvOptions
#

DEFAULT_TEST_BACKEND_HOST
#

testing/cross_backend/default_backend_configs.ts view source

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

The HOST both builders bind a backend to — loopback IPv4, since localhost can resolve to ::1 and a backend bound there misses a client that connects to 127.0.0.1 (the raw-socket suites, a git hook calling back). base_url stays http://localhost:<port>, which reaches it.

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 (Node + Bun). Owns the common env baseline (NODE_ENV, HOST, PORT, in-memory pglet, 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 names the tmpdir (default_test_backend_paths) 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 readonly string[]

readonly

database_url

Required — Rust needs real Postgres (an in-process WASM database 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

Every capability, stated: spread rust_default_capabilities and add each MountFlag and the testing_backdoors list. Required, so a mount flag or the backdoor list left out is a type error rather than a suite that silently skips.

type BackendCapabilities

readonly

paths?

Pre-computed paths; defaults to default_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

daemon_token_dir_env?

Env var naming the directory the binary writes its daemon token under ({dir}/run/daemon_token), e.g. 'MY_APP_DAEMON_TOKEN_DIR'. Given, it is set to the directory that layout puts the token at the bootstrap's daemon_token_path (to_daemon_token_dir) — the file spawn_backend reads — and a path in another layout throws. Omit it for a binary that derives the path otherwise.

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 names the tmpdir (default_test_backend_paths) 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 readonly string[]

readonly

database_url?

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

type string

readonly

extra_env?

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

type Readonly<Record<string, string>>

readonly

capabilities

Every capability, stated: spread ts_default_capabilities and add each MountFlag and the testing_backdoors list. Required, so a mount flag or the backdoor list left out is a type error rather than a suite that silently skips.

type BackendCapabilities

readonly

paths?

Pre-computed paths; defaults to default_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

daemon_token_dir_env?

Env var naming the directory the binary writes its daemon token under ({dir}/run/daemon_token), e.g. 'MY_APP_DAEMON_TOKEN_DIR'. Given, it is set to the directory that layout puts the token at the bootstrap's daemon_token_path (to_daemon_token_dir) — the file spawn_backend reads — and a path in another layout throws. Omit it for a binary that derives the path otherwise.

type string

readonly

rust_default_capabilities
#

timing_env
#

testing/cross_backend/default_backend_configs.ts view source

(options: TimingEnvOptions): Record<string, string> import {timing_env} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

The extra_env entries carrying the timing overrides, shared by the TS and Rust backend configs so one option drives both impls. Each value is passed through as given, so the binary refuses a bad one instead of the harness hiding it.

options

returns

Record<string, string>

TimingEnvOptions
#

testing/cross_backend/default_backend_configs.ts view source

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

Options for timing_env.

audit_sse_keep_alive_ms?

The audit stream's keep-alive interval in ms (AUDIT_SSE_KEEP_ALIVE_MS_ENV).

type number

readonly

ws_receive_timeout_ms?

The WS endpoints' receive timeout in ms (WS_RECEIVE_TIMEOUT_MS_ENV).

type number

readonly

db_checkout_timeout_ms?

The pool checkout bound of a request in ms (FUZ_DB_CHECKOUT_TIMEOUT_MS).

type number

readonly

db_audit_checkout_timeout_ms?

The pool checkout bound of an audit write in ms (FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS).

type number

readonly

to_daemon_token_dir
#

testing/cross_backend/default_backend_configs.ts view source

(daemon_token_path: string): string import {to_daemon_token_dir} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

The directory a binary writing its daemon token to {dir}/run/daemon_token is given, so the token lands at daemon_token_path.

daemon_token_path

where the harness reads the token

type string

returns

string

the {dir} of that layout

throws

  • Error - when the path is not `.../run/daemon_token`, which no such directory can produce

ts_default_capabilities
#

testing/cross_backend/default_backend_configs.ts view source

FamilyDefaultCapabilities import {ts_default_capabilities} from '@fuzdev/fuz_app/testing/cross_backend/default_backend_configs.js';

Capabilities shared by TS-family backends — only what the family guarantees: the declared spine surface's mounts and the behavior of its reference runtime, Node. Carries no MountFlag and no testing_backdoors; each backend config states those itself (FamilyDefaultCapabilities).

Depends on
#

Imported by
#