- add POST /import, an import page and the import_yaml mcp tool; items are validated up front and imported in dependency order - switch list page import buttons to the central import - write scenario exports as separate --- yaml documents per entity - give each test app its own files dir to avoid cross-suite races - use node: prefix for node built-in imports - bump version to 1.18.0
26 lines
747 B
TypeScript
26 lines
747 B
TypeScript
import {
|
|
CallHandler,
|
|
ExecutionContext,
|
|
Injectable,
|
|
NestInterceptor,
|
|
} from "@nestjs/common";
|
|
import * as crypto from "node:crypto";
|
|
import type { Request } from "express";
|
|
import { Observable } from "rxjs";
|
|
import { traceStorage } from "../common/trace-context";
|
|
|
|
@Injectable()
|
|
export class TraceInterceptor implements NestInterceptor {
|
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
|
const req = context.switchToHttp().getRequest<Request>();
|
|
const traceId =
|
|
(req.headers["x-trace-id"] as string | undefined) ?? crypto.randomUUID();
|
|
|
|
return new Observable((subscriber) => {
|
|
traceStorage.run({ traceId }, () => {
|
|
next.handle().subscribe(subscriber);
|
|
});
|
|
});
|
|
}
|
|
}
|