style: clean up code formatting and remove trailing whitespace

refactor: reorganize imports and fix type imports
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-11 03:08:36 -03:00
1 parent d3704602fd
commit 47c04de6fe
232 files changed
+7140 -4798

No files matched your search

+2 -7
View File
@@ -1,4 +1,4 @@
import { NextRequest } from "next/server";
import type { NextRequest } from "next/server";
import { prisma } from "@/lib/prisma/app";
export async function GET(_req: NextRequest) {
@@ -15,11 +15,6 @@ export async function GET(_req: NextRequest) {
.filter((category): category is string => Boolean(category)),
});
} catch (e: any) {
return Response.json(
{ error: e?.message || "Erro" },
{ status: 500 }
);
return Response.json({ error: e?.message || "Erro" }, { status: 500 });
}
}
+19 -9
View File
@@ -1,6 +1,6 @@
import { NextRequest } from "next/server";
import { searchItems, type ItemSort } from "@/lib/prisma/queries/items";
import type { NextRequest } from "next/server";
import { buildPublicItemImageUrl } from "@/lib/item-images";
import { type ItemSort, searchItems } from "@/lib/prisma/queries/items";
function parseArray(param: string | null): string[] {
if (!param) return [];
@@ -28,7 +28,8 @@ export async function GET(req: NextRequest) {
const rarities = parseArray(searchParams.get("rarity"));
const server = searchParams.get("server") || undefined;
const sortParamRaw = (searchParams.get("sort") || "name").toLowerCase();
const sortParam = (allowedSorts.find((sort) => sort === sortParamRaw) || "name") as ItemSort;
const sortParam = (allowedSorts.find((sort) => sort === sortParamRaw) ||
"name") as ItemSort;
const page = Number(searchParams.get("page") || "1");
const pageSize = Number(searchParams.get("pageSize") || "24");
@@ -48,7 +49,11 @@ export async function GET(req: NextRequest) {
return { ...item, image_url: img, image: img };
}
if (img.startsWith("data/")) {
return { ...item, image_url: img, image: `/api/images?path=${encodeURIComponent(img)}` };
return {
...item,
image_url: img,
image: `/api/images?path=${encodeURIComponent(img)}`,
};
}
const category = item.category || "other";
return {
@@ -60,8 +65,15 @@ export async function GET(req: NextRequest) {
const totalPages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
return Response.json(
{ items: itemsWithImage, page, pageSize, total, totalPages, sort: sortParam },
{ status: 200 }
{
items: itemsWithImage,
page,
pageSize,
total,
totalPages,
sort: sortParam,
},
{ status: 200 },
);
} catch (error: any) {
console.error("[api/items] Erro:", error?.message, error?.stack);
@@ -70,9 +82,7 @@ export async function GET(req: NextRequest) {
error: "Falha ao consultar itens",
message: error?.message || "Erro desconhecido",
},
{ status: 500 }
{ status: 500 },
);
}
}