migrate to root dir

This commit is contained in:
2025-08-08 19:26:21 +02:00
parent cf8219691b
commit 8720500442
41 changed files with 2478 additions and 4440 deletions

43
app/api/run/route.ts Normal file
View File

@@ -0,0 +1,43 @@
import path from "path";
import { runStoryPipeline } from "@/lib/pipeline/pipeline";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const maxDuration = 300; // seconds
type RunBody = {
storyName: string;
force?: boolean;
skipUpload?: boolean;
concurrency?: number;
};
function isRunBody(value: unknown): value is RunBody {
if (typeof value !== "object" || value === null) return false;
const v = value as Record<string, unknown>;
return typeof v.storyName === "string";
}
export async function POST(request: Request) {
const bodyUnknown: unknown = await request.json().catch(() => null);
if (!isRunBody(bodyUnknown)) {
return Response.json({ ok: false, error: "'storyName' is required" }, { status: 400 });
}
const storyName = bodyUnknown.storyName;
const force = !!bodyUnknown.force;
const skipUpload = !!bodyUnknown.skipUpload;
const concurrency = Math.max(1, Math.min(10, Number(bodyUnknown.concurrency) || 3));
// Keep using repo root for stories unless you move them into the Next.js folder
const baseDir = path.resolve(process.cwd(), "..");
try {
const result = await runStoryPipeline(storyName, { force, skipUpload, concurrency, baseDir });
return Response.json({ ok: true, result });
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
return Response.json({ ok: false, error: message }, { status: 500 });
}
}