diff options
author | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-06 16:08:43 -0300 |
---|---|---|
committer | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-06 16:08:43 -0300 |
commit | 75704b00718f6fe675975c90b27ee767fe5a71cb (patch) | |
tree | 959be76b25de3b11f6a74f32b1537d356a576bc2 /src/pages | |
parent | a8c6eb9542e4baba3ce05da454fc52548214ba06 (diff) |
fix: await promise
Signed-off-by: João Augusto Costa Branco Marado Torres <torres.dev@disroot.org>
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/outbox.json.ts | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/pages/outbox.json.ts b/src/pages/outbox.json.ts index cec761e..9e2505f 100644 --- a/src/pages/outbox.json.ts +++ b/src/pages/outbox.json.ts @@ -5,36 +5,35 @@ import { fromPosts, isOriginal } from "../lib/collection/helpers.ts"; const { PUBLIC_SITE_URL } = env; const site = new URL(PUBLIC_SITE_URL); -const orderedItems = fromPosts( - isOriginal, - (x) => - x.map(({ id, data, rendered }) => { - const { dateCreated, title } = data; - return { - id: new URL(`blog/read/${id}`, site).href, - type: "Create", - actor: new URL("actor.json", site).href, - published: dateCreated.toISOString(), - to: ["https://www.w3.org/ns/activitystreams#Public"], - object: { +export const GET: APIRoute = async (): Promise<Response> => { + const orderedItems = await fromPosts( + isOriginal, + (x) => + x.map(({ id, data, rendered }) => { + const { dateCreated, title } = data; + return { id: new URL(`blog/read/${id}`, site).href, - type: "Article", - name: title, - url: new URL(`blog/read/${id}`, site).href, - content: rendered?.html ?? "", - }, - }; - }), -); -const outbox = { - "@context": "https://www.w3.org/ns/activitystreams", - id: new URL("outbox.json", site).href, - type: "OrderedCollection", - totalItems: 1, - orderedItems, -}; - -export const GET: APIRoute = (): Response => { + type: "Create", + actor: new URL("actor.json", site).href, + published: dateCreated.toISOString(), + to: ["https://www.w3.org/ns/activitystreams#Public"], + object: { + id: new URL(`blog/read/${id}`, site).href, + type: "Article", + name: title, + url: new URL(`blog/read/${id}`, site).href, + content: rendered?.html ?? "", + }, + }; + }), + ); + const outbox = { + "@context": "https://www.w3.org/ns/activitystreams", + id: new URL("outbox.json", site).href, + type: "OrderedCollection", + totalItems: 1, + orderedItems, + }; return new Response(JSON.stringify(outbox), { headers: { "Content-Type": "application/activity+json" }, }); |