Initial commit
This commit is contained in:
21
functions/api/appeals/toggle.ts
Normal file
21
functions/api/appeals/toggle.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { active } = context.data.body;
|
||||
|
||||
if (typeof active !== "boolean")
|
||||
return new Response('{"error":"Active property must be a boolean"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 400,
|
||||
});
|
||||
|
||||
if (active) {
|
||||
await context.env.DATA.delete("appeal_disabled");
|
||||
} else {
|
||||
await context.env.DATA.put("appeal_disabled", "1");
|
||||
}
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user