feat(api): implement links routes
This commit is contained in:
15
server/api/links/index.post.ts
Normal file
15
server/api/links/index.post.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { db } from "#server/db";
|
||||
import * as tables from "#server/db/schema";
|
||||
import { z } from "zod";
|
||||
|
||||
const bodySchema = z.object({
|
||||
name: z.string().min(1),
|
||||
path: z.string().min(1),
|
||||
url: z.url().min(1),
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readValidatedBody(event, bodySchema.parse);
|
||||
const [link] = await db.insert(tables.links).values(body).returning();
|
||||
return link;
|
||||
});
|
||||
Reference in New Issue
Block a user