feat(backend): add foundation services and sql idempotency
This commit is contained in:
10
backend/command-api/src/middleware/idempotency.js
Normal file
10
backend/command-api/src/middleware/idempotency.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { AppError } from '../lib/errors.js';
|
||||
|
||||
export function requireIdempotencyKey(req, _res, next) {
|
||||
const idempotencyKey = req.get('Idempotency-Key');
|
||||
if (!idempotencyKey) {
|
||||
return next(new AppError('MISSING_IDEMPOTENCY_KEY', 'Missing Idempotency-Key header', 400));
|
||||
}
|
||||
req.idempotencyKey = idempotencyKey;
|
||||
return next();
|
||||
}
|
||||
Reference in New Issue
Block a user