Skip to content

Commit 361dc9f

Browse files
committed
Add export job status API endpoint
Implements GET /api/exports/[jobId] to retrieve export job status and download URL. Includes authentication and ownership checks, returning job details or appropriate error responses.
1 parent 01d1878 commit 361dc9f

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* GET /api/exports/[jobId]
3+
*
4+
* Get export job status and download URL
5+
*
6+
* Implements job status polling for async exports (T029)
7+
*
8+
* @requires Authentication
9+
* @returns Export job details with status and file URL (if completed)
10+
*/
11+
12+
import { NextRequest } from 'next/server';
13+
export const dynamic = 'force-dynamic';
14+
15+
import { createApiHandler, middlewareStacks } from '@/lib/api-middleware';
16+
import {
17+
successResponse,
18+
notFoundResponse,
19+
forbiddenResponse,
20+
} from '@/lib/api-response';
21+
import { getExportJobStatus } from '@/services/export-service';
22+
23+
export const GET = createApiHandler(
24+
middlewareStacks.authenticated,
25+
async (request: NextRequest, context) => {
26+
const jobId = context.params?.jobId;
27+
28+
if (!jobId) {
29+
return notFoundResponse('Job ID is required');
30+
}
31+
32+
const userId = context.session!.user.id;
33+
34+
// Fetch job status (enforces ownership)
35+
const job = await getExportJobStatus(jobId, userId);
36+
37+
if (!job) {
38+
return notFoundResponse('Export job not found');
39+
}
40+
41+
return successResponse(job, {
42+
message: 'Export job retrieved successfully',
43+
});
44+
}
45+
);

0 commit comments

Comments
 (0)