Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Finish appeal[id] middleware
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 5581730 commit 75005da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions functions/api/appeals/[id]/_middleware.ts
Expand Up @@ -10,15 +10,18 @@ export async function onRequestPost(context: RequestContext) {
});

const { body } = context.data;
const id = context.params.id as string;

if (typeof body.accept !== "boolean")
return new Response('{"error":"Invalid acceptance status"}', {
if (id.search(/^\d{16,19}$/) === -1)
return new Response('{"error":"Invalid target id"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});

context.data.targetId = id;

if (
body.feedback &&
(typeof body.feedback !== "string" || body.feedback.length > 512)
Expand All @@ -29,4 +32,6 @@ export async function onRequestPost(context: RequestContext) {
},
status: 400,
});

return await context.next();
}

0 comments on commit 75005da

Please sign in to comment.