31 lines
840 B
TypeScript
31 lines
840 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { requireAdmin } from "@/lib/admin-auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { discoverSkills } from "@/lib/skill-discoverer";
|
|
import { badRequest, notFound, serverError } from "@/lib/api-error";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
export async function POST(request: Request) {
|
|
const authError = await requireAdmin();
|
|
if (authError) return authError;
|
|
|
|
try {
|
|
const body = await request.json().catch(() => ({}));
|
|
const result = await discoverSkills(prisma, {
|
|
minStars: body.minStars ?? 500,
|
|
maxPerQuery: body.maxPerQuery ?? 5,
|
|
dailyLimit: body.dailyLimit ?? 10,
|
|
withReview: body.withReview ?? true,
|
|
queries: body.queries,
|
|
});
|
|
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return serverError(error);
|
|
}
|
|
}
|
|
|
|
|