Spaces:
Build error
Build error
File size: 921 Bytes
333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 333c51a 5cff373 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
export async function GET() {
try {
const repos = await db.repo.findMany({ orderBy: { createdAt: "desc" } });
return NextResponse.json({ success: true, repos });
} catch {
return NextResponse.json({ success: false, error: "Error" }, { status: 500 });
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { url, name, projectId } = body;
if (!url) {
return NextResponse.json({ success: false, error: "URL requerida" }, { status: 400 });
}
const repo = await db.repo.create({
data: { url, name: name || url.split("/").pop() || "repo", projectId: projectId || null }
});
return NextResponse.json({ success: true, repo });
} catch {
return NextResponse.json({ success: false, error: "Error" }, { status: 500 });
}
} |