From 0ab24448eab2f127ff58042d3c7e403e398c0867 Mon Sep 17 00:00:00 2001 From: Cody Bromley Date: Fri, 13 Sep 2024 14:44:31 -0500 Subject: [PATCH] remove health check --- deno.json | 2 +- mod.ts | 18 ------------------ mod_test.ts | 28 ---------------------------- package.json | 2 +- readme.md | 25 ++----------------------- 5 files changed, 4 insertions(+), 71 deletions(-) diff --git a/deno.json b/deno.json index f49fe93..82acae3 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@codybrom/denim", - "version": "1.1.0", + "version": "1.2.0", "description": "A Deno function for posting to Threads.", "entry": "./mod.ts", "exports": { diff --git a/mod.ts b/mod.ts index 230da39..86ce1fe 100644 --- a/mod.ts +++ b/mod.ts @@ -369,21 +369,3 @@ export async function getPublishingLimit( return data.data[0]; } - -/** - * Checks the health status of the Threads API. - * - * @returns A Promise that resolves to the health status - */ -export async function checkHealth(): Promise<{ status: string }> { - const response = await fetch(`${THREADS_API_BASE_URL}/health`); - const data = await response.json(); - - if (!response.ok) { - throw new Error( - `Health check failed: ${data.error?.message || response.statusText}` - ); - } - - return data; -} diff --git a/mod_test.ts b/mod_test.ts index 65e2f22..82993e0 100644 --- a/mod_test.ts +++ b/mod_test.ts @@ -8,7 +8,6 @@ import { publishThreadsContainer, createCarouselItem, getPublishingLimit, - checkHealth, type ThreadsPostRequest, } from "./mod.ts"; @@ -500,30 +499,3 @@ Deno.test("getPublishingLimit should throw error on failure", async () => { "Failed to get publishing limit" ); }); - -Deno.test("checkHealth should return OK status", async () => { - globalThis.fetch = (_input: string | URL | Request): Promise => { - return Promise.resolve({ - ok: true, - status: 200, - json: () => Promise.resolve({ status: "ok" }), - } as Response); - }; - - const result = await checkHealth(); - assertEquals(result.status, "ok"); -}); - -Deno.test("checkHealth should throw error on failure", async () => { - globalThis.fetch = (_input: string | URL | Request): Promise => { - return Promise.resolve({ - ok: false, - status: 500, - statusText: "Internal Server Error", - json: () => - Promise.resolve({ error: { message: "Service unavailable" } }), - } as Response); - }; - - await assertRejects(() => checkHealth(), Error, "Health check failed"); -}); diff --git a/package.json b/package.json index 39d941e..7beac18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codybrom/denim", - "version": "1.1.0", + "version": "1.2.0", "description": "Typescript/Deno module to simplify posting to Threads with text, images, or videos", "main": "mod.ts", "directories": { diff --git a/readme.md b/readme.md index a71d4c7..6f34897 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,6 @@ - Attach links to text posts - Geo-gate content to specific countries - Control who can reply to posts -- Check API health status - Retrieve publishing rate limit information - Ready to deploy as an edge function @@ -33,20 +32,13 @@ This will add the latest version of Denim to your project's dependencies. To import straight from JSR: ```typescript -import { ThreadsPostRequest, createThreadsContainer, publishThreadsContainer } from 'jsr:@codybrom/denim@^1.1.0'; +import { ThreadsPostRequest, createThreadsContainer, publishThreadsContainer } from 'jsr:@codybrom/denim@^1.2.0'; ``` ### Basic Usage ```typescript -import { createThreadsContainer, publishThreadsContainer, ThreadsPostRequest } from "jsr:@codybrom/denim@^1.1.0"; - -// Check API health before posting -const healthStatus = await checkHealth(); -if (healthStatus.status !== "ok") { - console.error("API is not healthy. Status:", healthStatus.status); - return; -} +import { createThreadsContainer, publishThreadsContainer, ThreadsPostRequest } from "jsr:@codybrom/denim@^1.2.0"; const request: ThreadsPostRequest = { userId: "YOUR_USER_ID", @@ -66,19 +58,6 @@ const publishedId = await publishThreadsContainer(request.userId, request.access console.log(`Post published with ID: ${publishedId}`); ``` -#### Checking API Health - -```typescript -import { checkHealth } from "jsr:@codybrom/denim@^1.2.0"; - -try { - const healthStatus = await checkHealth(); - console.log("API Health Status:", healthStatus.status); -} catch (error) { - console.error("Failed to check API health:", error); -} -``` - #### Retrieving Publishing Rate Limit ```typescript