mirror of
https://github.com/fccview/cronmaster.git
synced 2025-12-26 15:37:54 -05:00
29 lines
779 B
TypeScript
29 lines
779 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireAuth } from "@/app/_utils/api-auth-utils";
|
|
import { fetchScripts } from "@/app/_server/actions/scripts";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
/**
|
|
* GET /api/scripts - List all scripts
|
|
*/
|
|
export async function GET(request: NextRequest) {
|
|
const authError = await requireAuth(request);
|
|
if (authError) return authError;
|
|
|
|
try {
|
|
const scripts = await fetchScripts();
|
|
return NextResponse.json({ success: true, data: scripts });
|
|
} catch (error: any) {
|
|
console.error("[API] Error fetching scripts:", error);
|
|
return NextResponse.json(
|
|
{
|
|
success: false,
|
|
error: "Failed to fetch scripts",
|
|
message: error.message,
|
|
},
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|