changes shopping

This commit is contained in:
Evandro Fonseca Junior committed 2025-11-09 15:37:53 -03:00
1 parent 62ab5b2608
commit f4bc93bc8a
17 files changed
+2290 -1025

No files matched your search

+22
View File
@@ -17,6 +17,15 @@ export async function POST(request: NextRequest) {
scope === "server" && typeof body?.server === "string"
? body.server.trim()
: null;
const categories: string[] = Array.isArray(body?.categories)
? body.categories.filter((item: unknown) => typeof item === "string")
: [];
const servers: string[] = Array.isArray(body?.servers)
? body.servers.filter((item: unknown) => typeof item === "string")
: [];
const images: string[] = Array.isArray(body?.images)
? body.images.filter((item: unknown) => typeof item === "string")
: [];
if (!name || !description) {
return NextResponse.json(
@@ -33,6 +42,19 @@ export async function POST(request: NextRequest) {
description,
scope,
server,
categories,
servers,
images: images
.slice(0, 2)
.map((dataUrl) => {
const [meta, base64Part] = dataUrl.split(",");
const mimeMatch = meta?.match(/data:(.*);base64/);
return {
mimeType: mimeMatch?.[1] ?? "image/jpeg",
base64Data: base64Part ?? meta,
};
})
.filter((image) => image.base64Data),
});
return NextResponse.json(