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

23 lines
725 B
JavaScript
Raw Normal View History

2026-01-05 09:58:59 +07:00
import { NextResponse } from "next/server";
2026-02-20 17:05:46 +07:00
import { testSingleConnection } from "./testUtils.js";
2026-01-05 09:58:59 +07:00
// POST /api/providers/[id]/test - Test connection
export async function POST(request, { params }) {
try {
const { id } = await params;
2026-02-20 17:05:46 +07:00
const result = await testSingleConnection(id);
2026-01-05 09:58:59 +07:00
2026-02-20 17:05:46 +07:00
if (result.error === "Connection not found") {
2026-01-05 09:58:59 +07: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-05 09:58:59 +07:00
});
} catch (error) {
console.log("Error testing connection:", error);
return NextResponse.json({ error: "Test failed" }, { status: 500 });
}
}