@codybrom/denim 1.1.0 → 1.2.0
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/deno.json +1 -1
- package/mod.ts +0 -18
- package/mod_test.ts +0 -28
- package/package.json +1 -1
- package/readme.md +2 -23
package/deno.json
CHANGED
package/mod.ts
CHANGED
|
@@ -369,21 +369,3 @@ export async function getPublishingLimit(
|
|
|
369
369
|
|
|
370
370
|
return data.data[0];
|
|
371
371
|
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Checks the health status of the Threads API.
|
|
375
|
-
*
|
|
376
|
-
* @returns A Promise that resolves to the health status
|
|
377
|
-
*/
|
|
378
|
-
export async function checkHealth(): Promise<{ status: string }> {
|
|
379
|
-
const response = await fetch(`${THREADS_API_BASE_URL}/health`);
|
|
380
|
-
const data = await response.json();
|
|
381
|
-
|
|
382
|
-
if (!response.ok) {
|
|
383
|
-
throw new Error(
|
|
384
|
-
`Health check failed: ${data.error?.message || response.statusText}`
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return data;
|
|
389
|
-
}
|
package/mod_test.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
publishThreadsContainer,
|
|
9
9
|
createCarouselItem,
|
|
10
10
|
getPublishingLimit,
|
|
11
|
-
checkHealth,
|
|
12
11
|
type ThreadsPostRequest,
|
|
13
12
|
} from "./mod.ts";
|
|
14
13
|
|
|
@@ -500,30 +499,3 @@ Deno.test("getPublishingLimit should throw error on failure", async () => {
|
|
|
500
499
|
"Failed to get publishing limit"
|
|
501
500
|
);
|
|
502
501
|
});
|
|
503
|
-
|
|
504
|
-
Deno.test("checkHealth should return OK status", async () => {
|
|
505
|
-
globalThis.fetch = (_input: string | URL | Request): Promise<Response> => {
|
|
506
|
-
return Promise.resolve({
|
|
507
|
-
ok: true,
|
|
508
|
-
status: 200,
|
|
509
|
-
json: () => Promise.resolve({ status: "ok" }),
|
|
510
|
-
} as Response);
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
const result = await checkHealth();
|
|
514
|
-
assertEquals(result.status, "ok");
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
Deno.test("checkHealth should throw error on failure", async () => {
|
|
518
|
-
globalThis.fetch = (_input: string | URL | Request): Promise<Response> => {
|
|
519
|
-
return Promise.resolve({
|
|
520
|
-
ok: false,
|
|
521
|
-
status: 500,
|
|
522
|
-
statusText: "Internal Server Error",
|
|
523
|
-
json: () =>
|
|
524
|
-
Promise.resolve({ error: { message: "Service unavailable" } }),
|
|
525
|
-
} as Response);
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
await assertRejects(() => checkHealth(), Error, "Health check failed");
|
|
529
|
-
});
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
- Attach links to text posts
|
|
13
13
|
- Geo-gate content to specific countries
|
|
14
14
|
- Control who can reply to posts
|
|
15
|
-
- Check API health status
|
|
16
15
|
- Retrieve publishing rate limit information
|
|
17
16
|
- Ready to deploy as an edge function
|
|
18
17
|
|
|
@@ -33,20 +32,13 @@ This will add the latest version of Denim to your project's dependencies.
|
|
|
33
32
|
To import straight from JSR:
|
|
34
33
|
|
|
35
34
|
```typescript
|
|
36
|
-
import { ThreadsPostRequest, createThreadsContainer, publishThreadsContainer } from 'jsr:@codybrom/denim@^1.
|
|
35
|
+
import { ThreadsPostRequest, createThreadsContainer, publishThreadsContainer } from 'jsr:@codybrom/denim@^1.2.0';
|
|
37
36
|
```
|
|
38
37
|
|
|
39
38
|
### Basic Usage
|
|
40
39
|
|
|
41
40
|
```typescript
|
|
42
|
-
import { createThreadsContainer, publishThreadsContainer, ThreadsPostRequest } from "jsr:@codybrom/denim@^1.
|
|
43
|
-
|
|
44
|
-
// Check API health before posting
|
|
45
|
-
const healthStatus = await checkHealth();
|
|
46
|
-
if (healthStatus.status !== "ok") {
|
|
47
|
-
console.error("API is not healthy. Status:", healthStatus.status);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
41
|
+
import { createThreadsContainer, publishThreadsContainer, ThreadsPostRequest } from "jsr:@codybrom/denim@^1.2.0";
|
|
50
42
|
|
|
51
43
|
const request: ThreadsPostRequest = {
|
|
52
44
|
userId: "YOUR_USER_ID",
|
|
@@ -66,19 +58,6 @@ const publishedId = await publishThreadsContainer(request.userId, request.access
|
|
|
66
58
|
console.log(`Post published with ID: ${publishedId}`);
|
|
67
59
|
```
|
|
68
60
|
|
|
69
|
-
#### Checking API Health
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
import { checkHealth } from "jsr:@codybrom/denim@^1.2.0";
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const healthStatus = await checkHealth();
|
|
76
|
-
console.log("API Health Status:", healthStatus.status);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error("Failed to check API health:", error);
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
61
|
#### Retrieving Publishing Rate Limit
|
|
83
62
|
|
|
84
63
|
```typescript
|