v3: add backlinks between dumps (via either dump url or dump target url mentioned through dump description and dump comments)
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 43s

This commit is contained in:
khannurien
2026-06-21 20:30:03 +00:00
parent d038116de5
commit 4687a6b515
9 changed files with 234 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ import {
updateDump,
} from "../services/dump-service.ts";
import { getDumpVoters } from "../services/vote-service.ts";
import { getRelatedDumps } from "../services/backlink-service.ts";
const router = new Router({ prefix: "/api/dumps" });
@@ -104,6 +105,14 @@ router.get("/:dumpId/voters", async (ctx) => {
};
});
router.get("/:dumpId/related", async (ctx) => {
const requestingUserId = await parseOptionalAuth(ctx) ?? undefined;
const dump = getDump(ctx.params.dumpId, requestingUserId);
const related = getRelatedDumps(dump.id, requestingUserId);
const responseBody: APIResponse<Dump[]> = { success: true, data: related };
ctx.response.body = responseBody;
});
router.get("/", async (ctx) => {
const requestingUserId = await parseOptionalAuth(ctx) ?? undefined;
const { page, limit } = parsePagination(ctx.request.url.searchParams);