Skip to content

Commit 8a580e2

Browse files
committed
coderabbit suggestions: refuse non-post, result as json
1 parent a7e9d5b commit 8a580e2

File tree

1 file changed

+7
-1
lines changed
  • packages/database/supabase/functions/create-group

1 file changed

+7
-1
lines changed

packages/database/supabase/functions/create-group/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ Deno.serve(async (req) => {
3232
},
3333
});
3434
}
35+
if (req.method !== "POST") {
36+
return Response.json(
37+
{ msg: 'Method not allowed' },
38+
{ status: 405 }
39+
);
40+
}
3541

3642
// @ts-ignore Deno is not visible to the IDE
3743
const url = Deno.env.get("SUPABASE_URL");
@@ -84,7 +90,7 @@ Deno.serve(async (req) => {
8490
if (membershipResponse.error)
8591
return Response.json({ msg: `Failed to create membership for group ${group_id}`, error: membershipResponse.error.message }, { status: 500 });
8692

87-
const res = new Response(group_id);
93+
const res = Response.json({group_id});
8894

8995
if (originIsAllowed) {
9096
res.headers.set("Access-Control-Allow-Origin", origin as string);

0 commit comments

Comments
 (0)