Skip to main content
Every public symbol exported by @westyx-nexus/sdk-nodejs. All read methods are synchronous (cache-backed); only create, evaluateFlags, evaluateAB, and close are async.

Construction

NexusClient.create(config: NexusConfig): Promise<NexusClient>

Creates a client and runs a blocking initial sync.
The SSE stream and the polling timer start automatically once the initial sync succeeds.

Configs

client.getConfig(key: string): unknown

Returns the resolved config value, or undefined if the key is absent. An integer beyond Number.MAX_SAFE_INTEGER is returned as a bigint rather than a silently different number - see Config values.
a public-key client receives the same configs and flags a secret key does; what it does not receive is secrets, which are absent from the sync response entirely.

client.getConfigRaw(key: string): string | undefined

Returns the config value as JSON text, exactly as the SDK holds it, or undefined when the key is absent. See Config values for why this exists.

client.getAllConfigs(): Record<string, unknown>

Snapshot copy of every config key-value pair currently in the cache.

Feature flags

client.getFlag(key: string, defaultValue?: boolean): boolean

Returns the is_active state of a flag, or defaultValue (default false) when the key is absent.

client.hasFlag(key: string): boolean

Reports whether a flag exists in the current snapshot - distinguishing “absent” from “present and false”, which getFlag cannot since both return false.

client.getAllFlags(): Record<string, boolean>

Snapshot copy of every flag key-is_active pair in the cache.

client.evaluateFlags(keys: string[]): Promise<Record<string, boolean>>

Live network call to the server’s batch evaluator. Useful when you need the most recent state and don’t want to wait for the next sync.
Missing keys resolve to false - never throws for an unknown key.

client.evaluateAB(keys, userId, attributes?): Promise<Record<string, boolean>>

Per-user AB evaluation (requires the AB Testing add-on on your project).

Secrets (secret key only)

client.getSecret(key: string): string

Returns the plaintext value of a text-type secret.

client.getSecretFilePath(key: string): string | undefined

Returns the filesystem path of a file-type secret (PEM cert, JSON service account key, etc.), or undefined if the key does not exist or is a text-type secret.
The SDK writes the secret content to a temp file on every sync when the value changes. Old temp files for the same key are deleted automatically. client.close() removes all temp files.

Write API (secret key only)

The write API lets you create, update, and delete secrets programmatically. All three methods check the key type before making any network call - public keys throw NexusPublicKeyError immediately.

client.setSecret(key: string, value: string): Promise<void>

Creates or updates a secret (POST /v1/secrets, type: "text").

client.deleteSecret(key: string): Promise<void>

Deletes all versions of a secret (DELETE /v1/secrets/:key). Key is URL-encoded automatically.

client.deleteSecretVersion(key: string, version: number): Promise<void>

Deletes a specific version of a secret (DELETE /v1/secrets/:key?version=N).

Metadata

Sync / lifecycle

client.connectStream() / client.disconnectStream()

The stream starts automatically after the initial sync. Call disconnectStream() to opt out (e.g. on a “go offline” signal); call connectStream() to restart.

client.refresh(): Promise<void>

Refreshes the cache now, bypassing the TTL. Errors are thrown rather than logged, since the caller asked for this sync. A sync already in flight is awaited instead of a second one being started.

client.close(): Promise<void>

Stops the SSE connection, the polling timer, and removes all temp secret files. Always call on shutdown.

Error types

See Error handling for full semantics and examples.