Files
cloudlense/frontend/src/app/api/monitor/start/route.ts
T
Dennis 50e25e3ee8 refactor: flatten monorepo structure to backend/ frontend/ devops/
Rename subdirectories for a cleaner single-repo layout:
- website-monitoring-backend/  → backend/
- website-monitoring-frontend/ → frontend/
- website-monitoring-devops/   → devops/

Update all references in package.json scripts, CI workflows,
docker-compose, pre-commit hooks, and documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 00:25:29 +01:00

46 lines
1.1 KiB
TypeScript

import { NextResponse } from "next/server";
import { getSupabaseAdmin } from "@/lib/admin";
import { supabase } from "@/lib/supabase";
export async function POST(request: Request) {
try {
const { websiteId } = await request.json();
// Create a new scan
const { data: scan, error: scanError } = await supabase
.from("scans")
.insert([
{
website_id: websiteId,
status: "pending",
},
])
.select()
.single();
if (scanError) throw scanError;
// Trigger the analysis process
const response = await fetch("/api/analyze", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
websiteId,
scanId: scan.id,
}),
});
if (!response.ok) {
throw new Error("Failed to start analysis");
}
return NextResponse.json({ success: true, scanId: scan.id });
} catch (error) {
console.error("Monitor start error:", error);
return NextResponse.json(
{ error: "Failed to start monitoring" },
{ status: 500 },
);
}
}