completionId: cgen-705389ea99954080a2874f9a0d9ac760

cgen-705389ea99954080a2874f9a0d9ac760
This commit is contained in:
Builder.io 2025-11-08 21:06:40 +00:00
parent a30933cae8
commit 9f127907fc

View file

@ -78,12 +78,13 @@ export default async function handler(
// POST - Create new role mapping // POST - Create new role mapping
if (req.method === "POST") { if (req.method === "POST") {
try {
const { arm, discord_role, server_id, user_type } = req.body; const { arm, discord_role, server_id, user_type } = req.body;
if (!arm || !discord_role) { if (!arm || !discord_role) {
return res return res.status(400).json({
.status(400) error: "arm and discord_role are required",
.json({ error: "arm and discord_role are required" }); });
} }
const { data, error } = await supabase const { data, error } = await supabase
@ -99,10 +100,18 @@ export default async function handler(
if (error) { if (error) {
console.error("Supabase error:", error); console.error("Supabase error:", error);
return res.status(500).json({ error: "Failed to create mapping" }); return res.status(500).json({
error: `Failed to create mapping: ${error.message}`,
});
} }
return res.status(201).json(data); return res.status(201).json(data);
} catch (insertErr: any) {
console.error("Insert error:", insertErr);
return res.status(500).json({
error: `Insert error: ${insertErr?.message || "Unknown error"}`,
});
}
} }
// PUT - Update role mapping // PUT - Update role mapping