Files
Lebenslauf-App/src/pages/api/cv/[id]/update.ts
2026-04-24 18:43:42 +02:00

28 lines
727 B
TypeScript

import type { APIRoute } from 'astro';
import { updateCV } from '../../../../lib/db';
export const PUT: APIRoute = async ({ request, locals, params }) => {
try {
const user = locals.user;
const id = params.id!;
const body = await request.json();
updateCV(id, user.id, {
title: body.title,
template: body.template,
settings: body.settings,
public: body.public,
});
return new Response(JSON.stringify({ ok: true }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
} catch (err: any) {
return new Response(JSON.stringify({ error: err.message }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
};