/** * @module routes/statusRoutes */ import { Router } from 'express'; import { asyncHandler, AppError } from '../errors.js'; import { getJobStatus, getBatchJobStatus, getJobVerification, } from '../services/timestampService.js'; export const statusRoutes = Router(); // Static/more-specific routes first statusRoutes.post( '/batch', asyncHandler(async (req, res) => { const { jobIds } = req.body ?? {}; if (!Array.isArray(jobIds) || jobIds.length === 0) { throw new AppError('jobIds array is required', { status: 400, code: 'VALIDATION_ERROR' }); } const result = await getBatchJobStatus(req.auth, { jobIds }); res.json(result); }), ); statusRoutes.get( '/:jobId/verification', asyncHandler(async (req, res) => { const result = await getJobVerification(req.auth, req.params.jobId); res.json(result); }), ); statusRoutes.get( '/:jobId', asyncHandler(async (req, res) => { const { jobId } = req.params; if (!jobId) { throw new AppError('jobId is required', { status: 400, code: 'VALIDATION_ERROR' }); } const result = await getJobStatus(req.auth, jobId); res.json(result); }), );