9router/src/app/api/providers/[id]/test/route.js

24 lines
725 B
JavaScript
Raw Normal View History

2026-01-04 21:58:59 -05:00
import { NextResponse } from "next/server";
2026-02-20 05:05:46 -05:00
import { testSingleConnection } from "./testUtils.js";
2026-01-04 21:58:59 -05:00
// POST /api/providers/[id]/test - Test connection
export async function POST(request, { params }) {
try {
const { id } = await params;
2026-02-20 05:05:46 -05:00
const result = await testSingleConnection(id);
2026-01-04 21:58:59 -05:00
2026-02-20 05:05:46 -05:00
if (result.error === "Connection not found") {
2026-01-04 21:58:59 -05:00
return NextResponse.json({ error: "Connection not found" }, { status: 404 });
}
return NextResponse.json({
valid: result.valid,
error: result.error,
refreshed: result.refreshed || false,
2026-01-04 21:58:59 -05:00
});
} catch (error) {
console.log("Error testing connection:", error);
return NextResponse.json({ error: "Test failed" }, { status: 500 });
}
}