[READ ONLY MIRROR] Spark Social AppView Server github.com/sprksocial/server
atproto deno hono lexicon
1
fork

Configure Feed

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

at main 75 lines 2.2 kB view raw
1import { assertEquals } from "@std/assert"; 2import { assertMatch } from "@std/assert/match"; 3import { createMockApp, createMockContext } from "./util.ts"; 4import { createApp } from "../main.ts"; 5 6Deno.test("Basic Endpoints", async (t) => { 7 const app = createMockApp(); 8 await t.step("/", async () => { 9 const res = await app.request("/", { 10 headers: { 11 "Content-Type": "application/json", 12 }, 13 }); 14 15 assertEquals(res.status, 200); 16 }); 17 await t.step("/.well-known/did.json", async () => { 18 const res = await app.request("/.well-known/did.json", { 19 headers: { 20 "Content-Type": "application/json", 21 }, 22 }); 23 24 assertMatch( 25 await res.text(), 26 new RegExp( 27 [ 28 "^\\{", 29 '"@context":\\["https://www\\.w3\\.org/ns/did/v1","https://w3id\\.org/security/multikey/v1"\\],', 30 '"id":"(did:web:[^"]+)",', 31 '"verificationMethod":\\[\\{', 32 '"id":"\\1#atproto",', 33 '"type":"Multikey",', 34 '"controller":"\\1",', 35 '"publicKeyMultibase":"[a-zA-Z0-9]+"', 36 "\\}\\],", 37 '"service":\\[\\{', 38 '"id":"#sprk_appview",', 39 '"type":"SprkAppView",', 40 '"serviceEndpoint":"https?://[^"]+"', 41 "\\}\\]", 42 "\\}$", 43 ].join(""), 44 ), 45 ); 46 }); 47}); 48 49Deno.test("Health Check", async (t) => { 50 await t.step("succeeds when DB is healthy", async () => { 51 const ctx = createMockContext(); 52 ctx.db.ping = () => Promise.resolve(); 53 54 const app = createApp(ctx); 55 const res = await app.request("/xrpc/_health"); 56 57 assertEquals(res.status, 200); 58 const body = await res.json(); 59 assertEquals(typeof body.version, "string"); 60 assertEquals(body.error, undefined); 61 }); 62 63 await t.step("returns 503 when DB is unavailable", async () => { 64 const ctx = createMockContext(); 65 ctx.db.ping = () => Promise.reject(new Error("Connection failed")); 66 67 const app = createApp(ctx); 68 const res = await app.request("/xrpc/_health"); 69 70 assertEquals(res.status, 503); 71 const body = await res.json(); 72 assertEquals(typeof body.version, "string"); 73 assertEquals(body.error, "Database not connected"); 74 }); 75});