hermes-web/app/api/tokens/route.ts

23 lines
674 B
TypeScript
Raw Normal View History

2023-12-30 05:56:40 -05:00
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
import fetchUserWithImpersonation from "@/lib/fetch-user-impersonation";
2023-12-30 05:56:40 -05:00
export async function GET(req: Request) {
try {
const user = await fetchUserWithImpersonation(req)
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
2023-12-30 05:56:40 -05:00
}
const tokens = await db.apiKey.findMany({
where: {
userId: user.id
2023-12-30 05:56:40 -05:00
}
});
return NextResponse.json(tokens);
} catch (error) {
console.log("[TOKENS/GET]", error);
return new NextResponse("Internal Error", { status: 500 });
2023-12-30 05:56:40 -05:00
}
}