Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m12s
CI/CD Pipeline / Security Scanning (push) Successful in 2m21s
CI/CD Pipeline / Lint and Format (push) Failing after 36s
CI/CD Pipeline / Terraform Validation (push) Failing after 22s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 25s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 23s
Validation / validate-genesis (push) Successful in 26s
Validation / validate-terraform (push) Failing after 21s
Validation / validate-kubernetes (push) Failing after 9s
Validation / validate-smart-contracts (push) Failing after 8s
Validation / validate-security (push) Failing after 1m15s
Validation / validate-documentation (push) Failing after 15s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 26s
Verify Deployment / Verify Deployment (push) Failing after 56s
Add operator settlement terminal UI/API, swift-listener service, compliance idempotency gates, GRU reserve dashboards, and @dbis/integration-foundation for typed HYBX/ISO adapter contracts. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { Request, Response, NextFunction } from 'express';
|
|
import { createCorrelationContext, CORRELATION_ID_HEADER, REQUEST_ID_HEADER } from '@dbis/integration-foundation';
|
|
import { appendOmnlAudit } from '../../services/omnl-audit-log';
|
|
|
|
/** Attach trace/correlation ids and log every /omnl request (response status on finish). */
|
|
export function omnlAuditMiddleware(req: Request, res: Response, next: NextFunction): void {
|
|
const ctx = createCorrelationContext({
|
|
correlationId: String(req.headers[CORRELATION_ID_HEADER] ?? req.headers['x-omnl-trace-id'] ?? ''),
|
|
requestId: String(req.headers[REQUEST_ID_HEADER] ?? ''),
|
|
});
|
|
const traceId = ctx.correlationId;
|
|
res.setHeader('X-OMNL-Trace-Id', traceId);
|
|
res.setHeader(CORRELATION_ID_HEADER, ctx.correlationId);
|
|
res.setHeader(REQUEST_ID_HEADER, ctx.requestId);
|
|
const started = Date.now();
|
|
res.on('finish', () => {
|
|
appendOmnlAudit({
|
|
category: 'api',
|
|
action: `${req.method} ${req.path}`,
|
|
actor: req.headers['x-omnl-actor'] as string | undefined,
|
|
sourceSystem: (req.headers['x-omnl-source'] as string) || 'http',
|
|
traceId,
|
|
status: res.statusCode < 400 ? 'ok' : 'error',
|
|
metadata: {
|
|
statusCode: res.statusCode,
|
|
durationMs: Date.now() - started,
|
|
query: req.query,
|
|
},
|
|
});
|
|
});
|
|
next();
|
|
}
|