docs for memories
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-06-29 15:00:34 +01:00
parent 701d39982f
commit 421c96c814
14 changed files with 956 additions and 33 deletions

View File

@@ -0,0 +1,35 @@
import { handleApi } from "@/lib/api";
import { deleteResourceLink, updateResourceLink } from "@/lib/services/resource-links";
import { requireUser } from "@/lib/services/user";
export async function PATCH(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const body = await request.json();
return handleApi(async () => {
const { user } = await requireUser();
const link = await updateResourceLink({
userId: user.id,
id,
title: typeof body.title === "string" ? body.title : undefined,
url: typeof body.url === "string" ? body.url : undefined,
category: typeof body.category === "string" ? body.category : undefined,
notes: typeof body.notes === "string" || body.notes === null ? body.notes : undefined,
status: typeof body.status === "string" ? body.status : undefined,
});
return { link };
});
}
export async function DELETE(
_request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
return handleApi(async () => {
const { user } = await requireUser();
return deleteResourceLink(user.id, id);
});
}

View File

@@ -0,0 +1,15 @@
import { handleApi } from "@/lib/api";
import { exportResourceLinksToBacklog } from "@/lib/services/resource-links";
import { requireUser } from "@/lib/services/user";
export async function POST(request: Request) {
const body = await request.json();
return handleApi(async () => {
const { user } = await requireUser();
return exportResourceLinksToBacklog({
userId: user.id,
weekStart: String(body.weekStart ?? ""),
ids: Array.isArray(body.ids) ? body.ids.map(String) : [],
});
});
}

View File

@@ -0,0 +1,40 @@
import { handleApi } from "@/lib/api";
import { requireUser } from "@/lib/services/user";
import {
createResourceLink,
getResourceBacklogSections,
listResourceLinks,
type ResourceLinkStatus,
} from "@/lib/services/resource-links";
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const weekStart = searchParams.get("weekStart") ?? undefined;
const status = (searchParams.get("status") ?? undefined) as ResourceLinkStatus | undefined;
const includeSections = searchParams.get("includeSections") === "1";
return handleApi(async () => {
const { user } = await requireUser();
const [links, sections] = await Promise.all([
listResourceLinks(user.id, { weekStart, status }),
includeSections ? getResourceBacklogSections() : Promise.resolve([]),
]);
return { links, sections };
});
}
export async function POST(request: Request) {
const body = await request.json();
return handleApi(async () => {
const { user } = await requireUser();
const link = await createResourceLink({
userId: user.id,
date: String(body.date),
title: String(body.title ?? ""),
url: String(body.url ?? ""),
category: typeof body.category === "string" ? body.category : undefined,
notes: typeof body.notes === "string" ? body.notes : undefined,
});
return { link };
});
}