Add ET member deletion endpoint
This commit is contained in:
parent
8ada65b68d
commit
6dc26e40a1
@ -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) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
const { id, name } = context.data.body;
|
const { id, name } = context.data.body;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user