29 lines
787 B
TypeScript
29 lines
787 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getMimecastClient } from '@/lib/services/mimecast-client';
|
|
import { getMimecastStats } from '@/lib/services/mimecast-sync-service';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const client = getMimecastClient();
|
|
const [connection, stats] = await Promise.all([
|
|
client.testConnection(),
|
|
getMimecastStats().catch(() => null),
|
|
]);
|
|
|
|
return NextResponse.json({
|
|
configured: true,
|
|
connected: connection.ok,
|
|
accountName: connection.accountName,
|
|
packageName: connection.packageName,
|
|
error: connection.error,
|
|
stats,
|
|
});
|
|
} catch (err: any) {
|
|
return NextResponse.json({
|
|
configured: false,
|
|
connected: false,
|
|
error: err.message,
|
|
stats: null,
|
|
});
|
|
}
|
|
}
|