Initial import of verae-middleware from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 12:58:30 -04:00
commit 7a31f93c5b
66 changed files with 6590 additions and 0 deletions

23
src/routes/hashRoutes.js Normal file
View file

@ -0,0 +1,23 @@
/**
* @module routes/hashRoutes
*/
import { Router } from 'express';
import { asyncHandler, AppError } from '../errors.js';
import { lookupHash } from '../services/timestampService.js';
export const hashRoutes = Router();
hashRoutes.get(
'/:sha256',
asyncHandler(async (req, res) => {
const { sha256 } = req.params;
if (!sha256 || !/^[a-fA-F0-9]{64}$/.test(sha256)) {
throw new AppError('sha256 must be 64 hex chars', { status: 400, code: 'VALIDATION_ERROR' });
}
const includeAttached = req.query.includeAttached === 'true' || req.query.includeAttached === '1';
const includeTree = req.query.includeTree === 'true' || req.query.includeTree === '1';
const result = await lookupHash(req.auth, sha256, { includeAttached, includeTree });
res.json(result);
}),
);