Files
blog/write-server/src/app/api/hugo/route.ts
T
2026-06-21 20:42:44 +08:00

31 lines
826 B
TypeScript

import { NextResponse } from "next/server";
import { hugo } from "@/lib/hugo";
import { HUGO_PREVIEW } from "@/lib/config";
export async function GET() {
try {
const result = await hugo.start();
if (result.alreadyRunning || result.ok) {
return NextResponse.json({ running: true, url: HUGO_PREVIEW });
}
return NextResponse.json({ running: false, url: HUGO_PREVIEW });
} catch (error: unknown) {
return NextResponse.json(
{ error: error instanceof Error ? error.message : "Failed" },
{ status: 500 }
);
}
}
export async function DELETE() {
try {
hugo.stop();
return NextResponse.json({ running: false });
} catch (error: unknown) {
return NextResponse.json(
{ error: error instanceof Error ? error.message : "Failed" },
{ status: 500 }
);
}
}