@unito/integration-sdk
Version:
Integration SDK
23 lines (18 loc) • 561 B
text/typescript
import { Request, Response, NextFunction } from 'express';
import crypto from 'crypto';
import { RequestMetrics } from '../resources/requestMetrics.js';
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Express {
interface Locals {
requestMetrics: RequestMetrics;
requestId: string;
}
}
}
function start(_: Request, res: Response, next: NextFunction) {
res.locals.requestMetrics = RequestMetrics.startRequest();
res.locals.requestId = crypto.randomUUID();
next();
}
export default start;