Added redemptions & redeemable actions. Fixed a few bugs.
This commit is contained in:
@ -1,28 +1,23 @@
|
||||
import fetchUser from "@/lib/fetch-user";
|
||||
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 { searchParams } = new URL(req.url)
|
||||
let userId = searchParams.get('userId')
|
||||
|
||||
if (userId == null) {
|
||||
const user = await fetchUser(req);
|
||||
if (user != null) {
|
||||
userId = user.id as string;
|
||||
}
|
||||
const user = await fetchUserWithImpersonation(req)
|
||||
if (!user) {
|
||||
return new NextResponse("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const tokens = await db.apiKey.findMany({
|
||||
where: {
|
||||
userId: userId as string
|
||||
userId: user.id
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json(tokens);
|
||||
} catch (error) {
|
||||
console.log("[TOKENS/GET]", error);
|
||||
return new NextResponse("Internal Error", { status: 500});
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user