tezx
Version:
TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an
12 lines (11 loc) • 469 B
JavaScript
import { generateID } from "../helper/index.js";
export const requestID = (headerName = "X-Request-ID", contextKey = "requestID") => {
return function requestID(ctx, next) {
const existingID = ctx.headers?.get(headerName.toLowerCase()) ||
ctx.headers?.get(headerName);
const requestId = existingID || `req-${generateID()}`;
ctx[contextKey] = requestId;
ctx.header(headerName, requestId);
return next();
};
};