Client configuration
GStableClient accepts GStableClientOptions, which extends GStableHttpOptions.
Options reference
| Option | Required | Description |
|---|---|---|
apiKey | Yes | API secret from the dashboard. Do not prefix with Bearer ; the SDK adds Bearer <key> when building Authorization. If your string already starts with Bearer , it is passed through unchanged. |
baseUrl | No | Private API origin. Default: DEFAULT_BASE_URL — 'https://api.gstable.io/api/v1/' (trailing slash stripped internally before paths are appended). |
publicBaseUrl | No | Public API origin (no auth header). Default: DEFAULT_PUBLIC_BASE_URL — 'https://api.gstable.io/public/api/v1'. Used by client.capability.all(). |
fetchImpl | No | Inject typeof fetch for tests, custom agents, or non-standard runtimes. Defaults to globalThis.fetch. |
Exported constants
You can log or assert against the same defaults the SDK uses:
import { DEFAULT_BASE_URL, DEFAULT_PUBLIC_BASE_URL } from 'gstable-js';
Environment variables (convention)
The SDK does not read GSTABLE_API_KEY by itself. Typical pattern:
const client = new GStableClient({
apiKey: process.env.GSTABLE_API_KEY ?? '',
});
Validate non-empty before deployment; the constructor throws if apiKey is missing or whitespace-only.
Debug logging
When GSTABLE_DEBUG is '1' or 'true' (Node process.env), the HTTP layer logs each request as JSON to console.error: method, full URL, headers (including Authorization). Do not enable in production on shared logs.
Staging or custom gateways
Point baseUrl / publicBaseUrl at your environment:
const client = new GStableClient({
apiKey: process.env.GSTABLE_API_KEY,
baseUrl: 'https://staging-api.example.com/api/v1/',
publicBaseUrl: 'https://staging-api.example.com/public/api/v1',
});
Ensure paths still match what your environment exposes (same route structure as production unless documented otherwise).