@dotbots-boutique/server-sdk 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/client.js +10 -1
- package/dist/proxy/handlers.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,8 @@ These are injected automatically by the DotBots platform — no manual configura
|
|
|
32
32
|
```
|
|
33
33
|
DOTBOTS_APP_ID=uuid
|
|
34
34
|
DOTBOTS_APP_SECRET=...
|
|
35
|
-
|
|
35
|
+
PLATFORM_API_URL=https://api.dotbots.ai
|
|
36
|
+
DOTBOTS_PROXY_URL=https://proxy.dotbots.ai
|
|
36
37
|
ENVIRONMENT=test|prod
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -46,7 +47,7 @@ import { DotBotsBackend } from 'npm:@dotbots-boutique/server-sdk';
|
|
|
46
47
|
const dotbots = new DotBotsBackend({
|
|
47
48
|
appId: Deno.env.get('DOTBOTS_APP_ID')!,
|
|
48
49
|
appSecret: Deno.env.get('DOTBOTS_APP_SECRET')!,
|
|
49
|
-
apiUrl: Deno.env.get('
|
|
50
|
+
apiUrl: Deno.env.get('PLATFORM_API_URL') ?? 'https://api.dotbots.ai',
|
|
50
51
|
environment: Deno.env.get('ENVIRONMENT') ?? 'prod'
|
|
51
52
|
});
|
|
52
53
|
|
|
@@ -54,7 +55,7 @@ const dotbots = new DotBotsBackend({
|
|
|
54
55
|
await dotbots.initialize();
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
`initialize()`
|
|
58
|
+
`initialize()` must be called before any other methods. If `DOTBOTS_PROXY_URL` is set, the proxy URL is used directly. Otherwise it fetches the proxy URL from the platform.
|
|
58
59
|
|
|
59
60
|
## AI calls
|
|
60
61
|
|
package/dist/client.js
CHANGED
|
@@ -15,6 +15,15 @@ class DotBotsBackend {
|
|
|
15
15
|
this.environment = config.environment;
|
|
16
16
|
}
|
|
17
17
|
async initialize() {
|
|
18
|
+
const injectedProxyUrl = process.env.DOTBOTS_PROXY_URL;
|
|
19
|
+
if (injectedProxyUrl) {
|
|
20
|
+
this.proxyUrl = injectedProxyUrl;
|
|
21
|
+
console.log(JSON.stringify({
|
|
22
|
+
level: 'info',
|
|
23
|
+
message: `[DotBotsBackend] Proxy URL from env: ${injectedProxyUrl}`,
|
|
24
|
+
}));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
18
27
|
const response = await fetch(`${this.apiUrl}/api/proxy/config`, {
|
|
19
28
|
headers: this.baseHeaders(),
|
|
20
29
|
});
|
|
@@ -92,7 +101,7 @@ class DotBotsBackend {
|
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
async charge(featureCode, options) {
|
|
95
|
-
const response = await fetch(`${this.getProxyUrl()}/charge`, {
|
|
104
|
+
const response = await fetch(`${this.getProxyUrl()}/payments/charge`, {
|
|
96
105
|
method: 'POST',
|
|
97
106
|
headers: this.baseHeaders(),
|
|
98
107
|
body: JSON.stringify({
|
package/dist/proxy/handlers.js
CHANGED
|
@@ -80,7 +80,7 @@ function handleAiCall(store, decodeJwt, getFeatureConfig, processAiCall) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
// ---------------------------------------------------------------------------
|
|
83
|
-
// POST /charge
|
|
83
|
+
// POST /payments/charge
|
|
84
84
|
// ---------------------------------------------------------------------------
|
|
85
85
|
function handleCharge(store, decodeJwt, getFeatureConfig, processCharge) {
|
|
86
86
|
const authenticate = resolveAuth(store, decodeJwt);
|
package/package.json
CHANGED