import { db } from "@/lib/db" import { NextResponse } from "next/server"; import fetchUserWithImpersonation from "@/lib/fetch-user-impersonation"; export async function GET(req: Request) { try { const user = await fetchUserWithImpersonation(req) if (!user) { return NextResponse.json({ message: 'Unauthorized.', error: null, value: null }, { status: 401 }); } const tokens = await db.apiKey.findMany({ where: { userId: user.id } }); return NextResponse.json(tokens); } catch (error) { console.log("[TOKENS/GET]", error); return NextResponse.json({ message: 'Something went wrong', error: error, value: null }, { status: 500 }) } }