76f266645d
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
16 lines
516 B
TypeScript
16 lines
516 B
TypeScript
import { randomUUID } from 'crypto';
|
|
import { Injectable, NestMiddleware } from '@nestjs/common';
|
|
import { NextFunction, Request, Response } from 'express';
|
|
|
|
export const REQUEST_ID_HEADER = 'x-request-id';
|
|
|
|
@Injectable()
|
|
export class RequestIdMiddleware implements NestMiddleware {
|
|
use(req: Request, res: Response, next: NextFunction) {
|
|
const id = (req.headers[REQUEST_ID_HEADER] as string) || randomUUID();
|
|
req.headers[REQUEST_ID_HEADER] = id;
|
|
res.setHeader(REQUEST_ID_HEADER, id);
|
|
next();
|
|
}
|
|
}
|