Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add ET member deletion endpoint
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 8ada65b commit 6dc26e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions functions/api/events-team/team-members/user.ts
@@ -1,3 +1,29 @@
export async function onRequestDelete(context: RequestContext) {
const { id } = context.data.body;

if (
typeof id !== "string" ||
id.search(/\D/) ||
id.length > 19 ||
id.length < 17
)
return new Response('{"error":"Invalid ID"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});

await context.env.DATA.delete(`etmember_${id}`);
await context.env.D1.prepare("DELETE FROM et_members WHERE id = ?;")
.bind(id)
.run();

return new Response(null, {
status: 204,
});
}

export async function onRequestPost(context: RequestContext) {
const { id, name } = context.data.body;

Expand Down

0 comments on commit 6dc26e4

Please sign in to comment.