@aerostack/sdk-node 0.3.2 → 0.3.5
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 +57 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,25 +48,25 @@ The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https
|
|
|
48
48
|
### NPM
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
npm add
|
|
51
|
+
npm add @aerostack/sdk-node
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### PNPM
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
pnpm add
|
|
57
|
+
pnpm add @aerostack/sdk-node
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
### Bun
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
bun add
|
|
63
|
+
bun add @aerostack/sdk-node
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
### Yarn
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
yarn add
|
|
69
|
+
yarn add @aerostack/sdk-node
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
> [!NOTE]
|
|
@@ -411,7 +411,7 @@ You can override the default server globally by passing a server index to the `s
|
|
|
411
411
|
|
|
412
412
|
| # | Server | Description |
|
|
413
413
|
| --- | ----------------------------- | ----------------- |
|
|
414
|
-
| 0 | `https://api.aerostack.
|
|
414
|
+
| 0 | `https://api.aerostack.dev/v1` | Production |
|
|
415
415
|
| 1 | `http://localhost:8787/v1` | Local Development |
|
|
416
416
|
|
|
417
417
|
#### Example
|
|
@@ -536,6 +536,58 @@ const sdk = new SDK({ debugLogger: console });
|
|
|
536
536
|
```
|
|
537
537
|
<!-- End Debugging [debug] -->
|
|
538
538
|
|
|
539
|
+
## Backend Service Integration
|
|
540
|
+
|
|
541
|
+
> **SDK Type**: HTTP Client (API Calls)
|
|
542
|
+
|
|
543
|
+
This SDK is an **HTTP client** that makes API calls to the Aerostack backend. It's ideal for:
|
|
544
|
+
|
|
545
|
+
✅ **Use cases**:
|
|
546
|
+
- Calling Aerostack Auth/E-commerce APIs from backend services (Node.js, Express, Nest.js)
|
|
547
|
+
- Integrating Aerostack features into existing applications
|
|
548
|
+
- Building API wrappers and middleware
|
|
549
|
+
|
|
550
|
+
❌ **Not for**:
|
|
551
|
+
- Direct access to Cloudflare bindings (D1, KV, Queue, R2) - use `@aerostack/sdk` Server SDK instead
|
|
552
|
+
|
|
553
|
+
### Backend Wrapper Pattern
|
|
554
|
+
|
|
555
|
+
If you're building a **Cloudflare Worker** that needs both API calls AND direct binding access, use both SDKs:
|
|
556
|
+
|
|
557
|
+
```typescript
|
|
558
|
+
// In a Cloudflare Worker
|
|
559
|
+
import { AerostackServer } from '@aerostack/sdk'; // For DB/Queue/Storage bindings
|
|
560
|
+
import { SDK as NodeSDK } from '@aerostack/node'; // For Auth/API calls
|
|
561
|
+
|
|
562
|
+
export default {
|
|
563
|
+
async fetch(request: Request, env: Env) {
|
|
564
|
+
// Direct bindings (fast, no HTTP overhead)
|
|
565
|
+
const server = new AerostackServer(env);
|
|
566
|
+
|
|
567
|
+
// HTTP API client (for Auth, etc.)
|
|
568
|
+
const client = new NodeSDK({
|
|
569
|
+
apiKeyAuth: env.AEROSTACK_API_KEY,
|
|
570
|
+
serverURL: 'https://api.aerostack.dev/v1'
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// Use both together
|
|
574
|
+
const authResult = await client.authentication.authSignin({
|
|
575
|
+
email: "user@example.com",
|
|
576
|
+
password: "password"
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
await server.db.query(
|
|
580
|
+
'INSERT INTO audit_logs (user_id, action) VALUES (?, ?)',
|
|
581
|
+
[authResult.user.id, 'login']
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
return Response.json(authResult);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
For non-Worker backends (Node.js, Vercel, etc.), you only need this SDK.
|
|
590
|
+
|
|
539
591
|
# Development
|
|
540
592
|
|
|
541
593
|
## Maturity
|