Create event decision endpoint

This commit is contained in:
Regalijan 2024-02-20 17:10:23 -05:00
parent 6c378080cc
commit 51b8822d0a
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -0,0 +1,16 @@
import { jsonError } from "../../../../common.js";
export async function onRequestPost(context: RequestContext) {
if (typeof context.data.body.approved !== "boolean")
return jsonError("Decision type must be a boolean", 400);
await context.env.D1.prepare(
"UPDATE events SET approved = ?, pending = 0 WHERE id = ?;",
)
.bind(Number(context.data.body.approved), context.data.event.id)
.run();
return new Response(null, {
status: 204,
});
}