diff options
Diffstat (limited to 'app/api/cron/forms/status/route.ts')
| -rw-r--r-- | app/api/cron/forms/status/route.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/api/cron/forms/status/route.ts b/app/api/cron/forms/status/route.ts new file mode 100644 index 00000000..c0e27b2e --- /dev/null +++ b/app/api/cron/forms/status/route.ts @@ -0,0 +1,46 @@ +// app/api/cron/forms/status/route.ts +import { NextRequest } from 'next/server'; +import { getSyncJobStatus } from '../start/route'; + +export async function GET(request: NextRequest) { + try { + // URL에서 작업 ID 가져오기 + const searchParams = request.nextUrl.searchParams; + const syncId = searchParams.get('id'); + + if (!syncId) { + return Response.json({ + success: false, + error: 'Missing sync ID parameter' + }, { status: 400 }); + } + + // 작업 상태 조회 + const jobStatus = getSyncJobStatus(syncId); + + if (!jobStatus) { + return Response.json({ + success: false, + error: 'Sync job not found' + }, { status: 404 }); + } + + // 작업 상태 반환 + return Response.json({ + success: true, + status: jobStatus.status, + startTime: jobStatus.startTime, + endTime: jobStatus.endTime, + progress: jobStatus.progress, + result: jobStatus.result, + error: jobStatus.error + }, { status: 200 }); + + } catch (error: any) { + console.error('Error retrieving sync status:', error); + return Response.json({ + success: false, + error: error.message || 'Failed to retrieve sync status' + }, { status: 500 }); + } +}
\ No newline at end of file |
