🪻 distributed transcription service thistle.dunkirk.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: improve health endpoint

+28 -15
+2 -2
src/components/transcription.ts
··· 565 565 566 566 async checkHealth() { 567 567 try { 568 - const response = await fetch("/api/transcriptions/health"); 568 + const response = await fetch("/api/health"); 569 569 if (response.ok) { 570 570 const data = await response.json(); 571 - this.serviceAvailable = data.available; 571 + this.serviceAvailable = data.status === "healthy"; 572 572 } else { 573 573 this.serviceAvailable = false; 574 574 }
+3 -1
src/index.test.README.md
··· 55 55 - `PUT /api/passkeys/:id` - Update passkey name 56 56 - `DELETE /api/passkeys/:id` - Delete passkey 57 57 58 + ### Health Endpoint 59 + - `GET /api/health` - Check service health (database, whisper, storage) 60 + 58 61 ### Transcription Endpoints 59 - - `GET /api/transcriptions/health` - Check transcription service health 60 62 - `GET /api/transcriptions` - List user transcriptions 61 63 - `POST /api/transcriptions` - Upload audio file and start transcription 62 64 - `GET /api/transcriptions/:id` - Get transcription details
+13 -7
src/index.test.ts
··· 18 18 19 19 beforeAll(async () => { 20 20 try { 21 - const response = await fetch(`${BASE_URL}/api/transcriptions/health`, { 21 + const response = await fetch(`${BASE_URL}/api/health`, { 22 22 signal: AbortSignal.timeout(1000), 23 23 }); 24 24 serverAvailable = response.ok || response.status === 404; ··· 969 969 }); 970 970 }); 971 971 972 - describe("API Endpoints - Transcriptions", () => { 973 - describe("GET /api/transcriptions/health", () => { 972 + describe("API Endpoints - Health", () => { 973 + describe("GET /api/health", () => { 974 974 serverTest( 975 - "should return transcription service health status", 975 + "should return service health status with details", 976 976 async () => { 977 - const response = await fetch(`${BASE_URL}/api/transcriptions/health`); 977 + const response = await fetch(`${BASE_URL}/api/health`); 978 978 979 979 expect(response.status).toBe(200); 980 980 const data = await response.json(); 981 - expect(data).toHaveProperty("available"); 982 - expect(typeof data.available).toBe("boolean"); 981 + expect(data).toHaveProperty("status"); 982 + expect(data).toHaveProperty("timestamp"); 983 + expect(data).toHaveProperty("services"); 984 + expect(data.services).toHaveProperty("database"); 985 + expect(data.services).toHaveProperty("whisper"); 986 + expect(data.services).toHaveProperty("storage"); 983 987 }, 984 988 ); 985 989 }); 990 + }); 986 991 992 + describe("API Endpoints - Transcriptions", () => { 987 993 describe("GET /api/transcriptions", () => { 988 994 serverTest("should return user transcriptions", async () => { 989 995 // Register user
+10 -5
src/index.ts
··· 1814 1814 } 1815 1815 }, 1816 1816 }, 1817 - "/api/transcriptions/health": { 1817 + "/api/health": { 1818 1818 GET: async () => { 1819 1819 const health = { 1820 1820 status: "healthy", ··· 1853 1853 1854 1854 // Check storage (uploads and transcripts directories) 1855 1855 try { 1856 - const uploadsDir = Bun.file("./uploads"); 1857 - const transcriptsDir = Bun.file("./transcripts"); 1858 - const uploadsExists = await uploadsDir.exists(); 1859 - const transcriptsExists = await transcriptsDir.exists(); 1856 + const fs = await import("node:fs/promises"); 1857 + const uploadsExists = await fs 1858 + .access("./uploads") 1859 + .then(() => true) 1860 + .catch(() => false); 1861 + const transcriptsExists = await fs 1862 + .access("./transcripts") 1863 + .then(() => true) 1864 + .catch(() => false); 1860 1865 health.services.storage = uploadsExists && transcriptsExists; 1861 1866 if (!health.services.storage) { 1862 1867 health.status = "unhealthy";