Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
/**
|
|
* @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);
|
|
}),
|
|
);
|