Files
pagodera/app/api/admin/items/analyze/route.ts
T
Evandro Fonseca Junior 62ab5b2608 feat(admin): centralize subscriptions under /admin?tab=subscriptions
Replaced the dedicated /admin/subscriptions page with a redirect to the central admin panel’s subscriptions tab. Removed session checks, imports, and the AdminSubscriptionDashboard since routing and access are now handled centrally. This streamlines admin UX and keeps access control unified.
2025-11-09 01:50:50 -03:00

47 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { requireAdminUser } from "@/lib/auth/middleware";
import { generateItemStructure } from "@/lib/ai/generate-item-structure";
export async function POST(request: NextRequest) {
const auth = await requireAdminUser(request);
if (auth instanceof NextResponse) {
return auth;
}
const body = await request.json();
const name = typeof body?.name === "string" ? body.name.trim() : "";
const description =
typeof body?.description === "string" ? body.description.trim() : "";
const scope = body?.scope === "server" ? "server" : "global";
const server =
scope === "server" && typeof body?.server === "string"
? body.server.trim()
: null;
if (!name || !description) {
return NextResponse.json(
{
success: false,
error: "Informe nome e descrição para gerar o JSON estrutural.",
},
{ status: 400 }
);
}
const result = await generateItemStructure({
name,
description,
scope,
server,
});
return NextResponse.json(
{
success: true,
structure: result.structure,
},
{ status: 200 }
);
}