24 lines
660 B
TypeScript
24 lines
660 B
TypeScript
|
|
import { NextRequest, NextResponse } from "next/server";
|
||
|
|
import { testFtpConnection } from "@/lib/ftp-watcher";
|
||
|
|
|
||
|
|
export async function POST(request: NextRequest) {
|
||
|
|
try {
|
||
|
|
const body = await request.json();
|
||
|
|
const result = await testFtpConnection({
|
||
|
|
host: body.host,
|
||
|
|
port: body.port || 21,
|
||
|
|
user: body.user,
|
||
|
|
pass: body.pass,
|
||
|
|
tls: body.tls ?? true,
|
||
|
|
incomingDir: body.incomingDir || "/incoming",
|
||
|
|
});
|
||
|
|
return NextResponse.json(result);
|
||
|
|
} catch (error) {
|
||
|
|
console.error("[ftp-watch/test POST]", error);
|
||
|
|
return NextResponse.json(
|
||
|
|
{ ok: false, error: "Test failed" },
|
||
|
|
{ status: 500 }
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|