This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
@@ -10,38 +10,41 @@ import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(_req: Request, { params }: { params: Promise<{ username: string }> }) {
|
||||
const { username } = await params;
|
||||
export async function GET(
|
||||
_req: Request,
|
||||
{ params }: { params: Promise<{ username: string }> },
|
||||
) {
|
||||
const { username } = await params;
|
||||
|
||||
try {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { username },
|
||||
select: {
|
||||
username: true,
|
||||
look: true,
|
||||
motto: true,
|
||||
rank: true,
|
||||
credits: true,
|
||||
online: true,
|
||||
accountCreated: true,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { username },
|
||||
select: {
|
||||
username: true,
|
||||
look: true,
|
||||
motto: true,
|
||||
rank: true,
|
||||
credits: true,
|
||||
online: true,
|
||||
accountCreated: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
return apiJson({ error: "User not found" }, { status: 404 });
|
||||
}
|
||||
if (!user) {
|
||||
return apiJson({ error: "User not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
return apiJson({
|
||||
username: user.username,
|
||||
look: user.look,
|
||||
motto: user.motto,
|
||||
rank: user.rank,
|
||||
credits: user.credits,
|
||||
online: user.online === "1",
|
||||
accountCreated: user.accountCreated,
|
||||
});
|
||||
} catch {
|
||||
// DB unreachable — behave as "not found" rather than 500.
|
||||
return apiJson({ error: "User not found" }, { status: 404 });
|
||||
}
|
||||
return apiJson({
|
||||
username: user.username,
|
||||
look: user.look,
|
||||
motto: user.motto,
|
||||
rank: user.rank,
|
||||
credits: user.credits,
|
||||
online: user.online === "1",
|
||||
accountCreated: user.accountCreated,
|
||||
});
|
||||
} catch {
|
||||
// DB unreachable — behave as "not found" rather than 500.
|
||||
return apiJson({ error: "User not found" }, { status: 404 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user