chore(repo): restructure as monorepo with server and client workspaces
- move NestJS app into server/ subdirectory - add client/ React+TypeScript (Vite) app with Hello World - update docker-compose to build and run both services - add root package.json declaring npm workspaces - update .gitignore to cover node_modules and dist at all depths
This commit is contained in:
1 parent
afc4627353
commit
5cc16725fb
88 files changed
+12637
-405
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
} from "@nestjs/common";
|
||||
import type { Request } from "express";
|
||||
import * as crypto from "crypto";
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user