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): string | undefined

Returns the resolved config value, or undefined if the key is absent.
public-key clients only see configs where is_public: true.

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

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.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).
Throws NexusAbAddonNotAvailableError (HTTP 403) if the AB Testing add-on is not active on this 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.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.