chore(landing): general cleanup + ui touchup

This commit is contained in:
cnrad
2024-11-11 22:16:26 -05:00
parent 8ba5d6544c
commit 4a9c696be4
17 changed files with 635 additions and 1344 deletions

View File

@@ -5,81 +5,75 @@ import { NextRequest } from "next/server";
export const dynamic = "force-dynamic";
export async function GET(
req: NextRequest,
options: { params: Promise<{ id: string[] }> },
) {
const userId = (await options.params).id.join("/");
export async function GET(req: NextRequest, options: { params: Promise<{ id: string[] }> }) {
const userId = (await options.params).id.join("/");
if (!userId)
return Response.json(
{
data: {
error: "No ID provided.",
},
success: false,
},
{
status: 400,
},
);
if (!isSnowflake(userId))
return Response.json(
{
data: {
error: "The ID you provide is not a valid snowflake.",
},
success: false,
},
{
status: 400,
},
);
let getUser: any = {};
getUser.data = await fetch(`https://api.lanyard.rest/v1/users/${userId}`, {
cache: "no-store",
}).then(async (res) => {
const data = await res.json();
if (!data.success) {
getUser.error = data.error;
}
return data;
});
if (getUser.error) {
return Response.json(
{
data: getUser.error,
success: false,
},
{
status: 400,
},
);
}
const params: Parameters = Object.fromEntries(
req.nextUrl.searchParams.entries(),
if (!userId)
return Response.json(
{
data: {
error: "No ID provided.",
},
success: false,
},
{
status: 400,
},
);
try {
let user = await redis.hget("users", userId);
if (!user) await redis.hset("users", userId, "true");
} catch {
null;
if (!isSnowflake(userId))
return Response.json(
{
data: {
error: "The ID you provide is not a valid snowflake.",
},
success: false,
},
{
status: 400,
},
);
let getUser: any = {};
getUser.data = await fetch(`https://api.lanyard.rest/v1/users/${userId}`, {
cache: "no-store",
}).then(async res => {
const data = await res.json();
if (!data.success) {
getUser.error = data.error;
}
return new Response(await renderCard(getUser.data, params), {
headers: {
"Content-Type": "image/svg+xml; charset=utf-8",
"content-security-policy":
"default-src 'none'; img-src * data:; style-src 'unsafe-inline'",
},
status: 200,
});
return data;
});
if (getUser.error) {
return Response.json(
{
data: getUser.error,
success: false,
},
{
status: 400,
},
);
}
const params: Parameters = Object.fromEntries(req.nextUrl.searchParams.entries());
try {
let user = await redis.hget("users", userId);
if (!user) await redis.hset("users", userId, "true");
} catch {
null;
}
return new Response(await renderCard(getUser.data, params), {
headers: {
"Content-Type": "image/svg+xml; charset=utf-8",
"content-security-policy": "default-src 'none'; img-src * data:; style-src 'unsafe-inline'",
},
status: 200,
});
}