added frontend + securing beta server invites
This commit is contained in:
27
web/app/api/guilds/[guildId]/roles/route.ts
Normal file
27
web/app/api/guilds/[guildId]/roles/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { auth } from "@/auth";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getGuildRoles } from "@/lib/discord";
|
||||
|
||||
// GET - Fetch all roles for a guild
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ guildId: string }> }
|
||||
) {
|
||||
const session = await auth();
|
||||
const { guildId } = await params;
|
||||
|
||||
if (!session?.accessToken) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const roles = await getGuildRoles(guildId, session.accessToken as string);
|
||||
return NextResponse.json(roles);
|
||||
} catch (error) {
|
||||
console.error("Error fetching roles:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Internal server error" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user