@autoblogwriter/sdk 2.0.1 → 2.0.2
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 +10 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @autoblogwriter/sdk
|
|
2
2
|
|
|
3
|
-
Official TypeScript SDK for
|
|
3
|
+
Official TypeScript SDK for AutoBlogWriter. It keeps server-side integration tiny, adds helpers for Next.js App Router and Vite/React apps, and ships revalidation utilities that respect AutoBlogWriter's API contract.
|
|
4
|
+
|
|
5
|
+
**[Documentation](https://docs.autoblogwriter.app/)**
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -11,7 +13,7 @@ npm install @autoblogwriter/sdk
|
|
|
11
13
|
> Requires Node.js 18+ and native `fetch`. Bundles ship as ESM, CJS, and types via `tsup`.
|
|
12
14
|
|
|
13
15
|
## Security Notes (Read First)
|
|
14
|
-
- Never ship
|
|
16
|
+
- Never ship AutoBlogWriter API keys in public, client-side code.
|
|
15
17
|
- Run the SDK inside Next.js server components, route handlers, or your own backend proxy.
|
|
16
18
|
- If you must expose functionality to the browser, issue scoped public tokens or proxy through your server. Do **not** mint new auth schemes.
|
|
17
19
|
|
|
@@ -21,7 +23,7 @@ npm install @autoblogwriter/sdk
|
|
|
21
23
|
import { createBlogAutoClient } from "@autoblogwriter/sdk";
|
|
22
24
|
|
|
23
25
|
const client = createBlogAutoClient({
|
|
24
|
-
apiUrl: "https://api.
|
|
26
|
+
apiUrl: "https://api.autoblogwriter.app",
|
|
25
27
|
apiKey: process.env.BLOGAUTO_API_KEY!,
|
|
26
28
|
workspaceId: process.env.BLOGAUTO_WORKSPACE_ID,
|
|
27
29
|
workspaceSlug: process.env.BLOGAUTO_WORKSPACE_SLUG,
|
|
@@ -34,8 +36,8 @@ const client = createBlogAutoClient({
|
|
|
34
36
|
|
|
35
37
|
| Option | Type | Required | Description |
|
|
36
38
|
| --- | --- | --- | --- |
|
|
37
|
-
| `apiUrl` | `string` | yes | Root API URL, e.g. `https://api.
|
|
38
|
-
| `apiKey` | `string` | yes | Workspace-scoped API key created in the
|
|
39
|
+
| `apiUrl` | `string` | yes | Root API URL, e.g. `https://api.autoblogwriter.app`. Trailing slash removed automatically. |
|
|
40
|
+
| `apiKey` | `string` | yes | Workspace-scoped API key created in the AutoBlogWriter dashboard. |
|
|
39
41
|
| `workspaceId` | `string` | one of `workspaceId` or `workspaceSlug` | Optional; used for account scoping. |
|
|
40
42
|
| `workspaceSlug` | `string` | one of `workspaceId` or `workspaceSlug` | Required for public content APIs (`/v1/public/:workspaceSlug/...`). |
|
|
41
43
|
| `authMode` | `"bearer" \| "x-api-key"` | no (default `"bearer"`) | Sends the API key via `Authorization: Bearer` or `x-api-key`. |
|
|
@@ -210,10 +212,10 @@ export function BlogList() {
|
|
|
210
212
|
|
|
211
213
|
## Automatic Revalidation Setup
|
|
212
214
|
|
|
213
|
-
When
|
|
215
|
+
When AutoBlogWriter publishes a post it can ping your Next.js App Router site so sitemap, robots, and cached blog pages refresh immediately.
|
|
214
216
|
|
|
215
217
|
1. **Configure your workspace**
|
|
216
|
-
- In the
|
|
218
|
+
- In the AutoBlogWriter dashboard open **Workspace Settings → Revalidation URL** and set your endpoint (e.g., `https://yoursite.com/api/blogauto/revalidate`).
|
|
217
219
|
- Generate a **Revalidation Webhook secret**, copy the plain secret once, and store it as `BLOGAUTO_REVALIDATE_SECRET`.
|
|
218
220
|
2. **Create the route handler**
|
|
219
221
|
|
|
@@ -238,7 +240,7 @@ export const POST = createRevalidateRouteHandler({
|
|
|
238
240
|
});
|
|
239
241
|
```
|
|
240
242
|
|
|
241
|
-
The handler verifies the `X-BlogAuto-Signature` HMAC header, enforces timestamp skew (default 5
|
|
243
|
+
The handler verifies the `X-BlogAuto-Signature` HMAC header, enforces timestamp skew (default 5 minutes), and revalidates:
|
|
242
244
|
|
|
243
245
|
- Paths: `/sitemap.xml`, `/robots.txt`, `/blog`, `/blog/:slug`
|
|
244
246
|
- Tags: `blogauto:<workspaceSlug>:sitemap`, `blogauto:<workspaceSlug>:posts`, and `blogauto:<workspaceSlug>:post:<slug>`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autoblogwriter/sdk",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Official
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Official AutoBlogWriter SDK for fetching posts, building sitemaps, rendering helpers, and revalidation utilities.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.cjs",
|