feat: add platform binding runtime config
This commit is contained in:
@@ -43,7 +43,7 @@ await platformClient.emailConnector.sendEmail({
|
||||
});
|
||||
```
|
||||
|
||||
The client connects to the platform endpoint configured through `SERVEZONE_API_DOMAIN`.
|
||||
The client connects to the platform endpoint configured through `SERVEZONE_PLATFORM_URL`, a runtime platform binding, or the legacy `SERVEZONE_API_DOMAIN` fallback.
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -51,14 +51,25 @@ The client needs two values:
|
||||
|
||||
| Value | How to provide it | Notes |
|
||||
| --- | --- | --- |
|
||||
| Authorization token | Constructor argument, `init()` argument, or `SERVEZONE_PLATFROM_AUTHORIZATION` | The current environment variable name is intentionally documented as implemented. |
|
||||
| API domain | `SERVEZONE_API_DOMAIN` | Loaded on demand through `@push.rocks/qenv`. |
|
||||
| Authorization token | Constructor argument, `init()` argument, `SERVEZONE_PLATFORM_AUTHORIZATION`, `SERVEZONE_PLATFORM_TOKEN`, binding credential env, or `SERVEZONE_PLATFROM_AUTHORIZATION` | The misspelled legacy env name remains supported for compatibility. |
|
||||
| Platform URL | Constructor options, `SERVEZONE_PLATFORM_URL`, binding endpoint, or `SERVEZONE_API_DOMAIN` | Loaded on demand through `@push.rocks/qenv`. |
|
||||
| Runtime bindings | Constructor options, `SERVEZONE_PLATFORM_BINDING`, or `SERVEZONE_PLATFORM_BINDINGS` | Values are JSON-encoded `IPlatformBinding` objects from `@serve.zone/interfaces`. |
|
||||
|
||||
```typescript
|
||||
const client = new SzPlatformClient();
|
||||
await client.init('your-platform-authorization-token');
|
||||
```
|
||||
|
||||
Constructor and `init()` also accept options:
|
||||
|
||||
```typescript
|
||||
const client = new SzPlatformClient({
|
||||
token: process.env.SERVEZONE_PLATFORM_TOKEN,
|
||||
platformUrl: process.env.SERVEZONE_PLATFORM_URL,
|
||||
});
|
||||
await client.init();
|
||||
```
|
||||
|
||||
## Debug Mode
|
||||
|
||||
Pass `test` as the authorization string to enable debug mode. In debug mode, the client does not open a TypedSocket connection and connector methods log or return deterministic test values instead of sending real platform requests.
|
||||
|
||||
Reference in New Issue
Block a user