Initial import of verae-middleware from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 13:31:59 -04:00
commit 72e143a8e5
66 changed files with 6590 additions and 0 deletions

View file

@ -0,0 +1,61 @@
/**
* @module routes/timestampRoutes
*/
import { Router } from 'express';
import { asyncHandler, AppError } from '../errors.js';
import {
createTimestamp,
createTimestampAndWait,
createBatchTimestamp,
} from '../services/timestampService.js';
export const timestampRoutes = Router();
timestampRoutes.post(
'/',
asyncHandler(async (req, res) => {
const { data, hashAlg, sha256, publicMetadata, privateMetadata } = req.body ?? {};
if (!data && !sha256) {
throw new AppError('data or sha256 is required', { status: 400, code: 'VALIDATION_ERROR' });
}
const result = await createTimestamp(req.auth, {
data,
hashAlg,
sha256,
publicMetadata,
privateMetadata,
});
res.status(202).json(result);
}),
);
timestampRoutes.post(
'/wait',
asyncHandler(async (req, res) => {
const { data, hashAlg, sha256, publicMetadata, privateMetadata } = req.body ?? {};
if (!data && !sha256) {
throw new AppError('data or sha256 is required', { status: 400, code: 'VALIDATION_ERROR' });
}
const result = await createTimestampAndWait(req.auth, {
data,
hashAlg,
sha256,
publicMetadata,
privateMetadata,
});
res.json(result);
}),
);
timestampRoutes.post(
'/batch',
asyncHandler(async (req, res) => {
const { items } = req.body ?? {};
if (!Array.isArray(items) || items.length === 0) {
throw new AppError('items array is required', { status: 400, code: 'VALIDATION_ERROR' });
}
const result = await createBatchTimestamp(req.auth, { items });
res.status(202).json(result);
}),
);