completionId: cgen-5828f4bc911640c7ab9888129e0d788e
cgen-5828f4bc911640c7ab9888129e0d788e
This commit is contained in:
parent
6977313a86
commit
a30933cae8
1 changed files with 26 additions and 11 deletions
|
|
@ -44,21 +44,36 @@ export default async function handler(
|
|||
}
|
||||
|
||||
try {
|
||||
// Validate Supabase is initialized
|
||||
if (!supabase) {
|
||||
console.error("Supabase client not initialized");
|
||||
return res.status(500).json({
|
||||
error: "Server configuration error: Missing Supabase credentials",
|
||||
});
|
||||
}
|
||||
|
||||
// GET - Fetch all role mappings
|
||||
if (req.method === "GET") {
|
||||
const { data, error } = await supabase
|
||||
.from("discord_role_mappings")
|
||||
.select("*")
|
||||
.order("created_at", { ascending: false });
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from("discord_role_mappings")
|
||||
.select("*")
|
||||
.order("created_at", { ascending: false });
|
||||
|
||||
if (error) {
|
||||
console.error("Supabase error:", error);
|
||||
return res
|
||||
.status(500)
|
||||
.json({ error: "Failed to fetch role mappings" });
|
||||
if (error) {
|
||||
console.error("Supabase error:", error);
|
||||
return res.status(500).json({
|
||||
error: `Failed to fetch role mappings: ${error.message}`,
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(data || []);
|
||||
} catch (queryErr: any) {
|
||||
console.error("Query error:", queryErr);
|
||||
return res.status(500).json({
|
||||
error: `Database query error: ${queryErr?.message || "Unknown error"}`,
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(data || []);
|
||||
}
|
||||
|
||||
// POST - Create new role mapping
|
||||
|
|
|
|||
Loading…
Reference in a new issue