feat(api): implement links routes

This commit is contained in:
2026-03-18 00:25:00 +01:00
parent 3be2034a49
commit 0c8677f514
5 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { db } from "#server/db";
import * as tables from "#server/db/schema";
import { eq } from "drizzle-orm";
import { z } from "zod";
const paramsSchema = z.object({
id: z.number(),
});
export default defineEventHandler(async (event) => {
const params = await getValidatedRouterParams(event, paramsSchema.parse);
const link = await db.query.links.findFirst({
where: eq(tables.links.id, params.id),
});
if (!link) {
throw createError({ statusCode: 404, message: "Link not found" });
}
return link;
});