mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
fix(server): use ClsInterceptor on websocket (#9859)
https://papooch.github.io/nestjs-cls/considerations/compatibility#websockets
This commit is contained in:
@@ -52,17 +52,28 @@ import { ENABLED_PLUGINS } from './plugins/registry';
|
||||
export const FunctionalityModules = [
|
||||
ClsModule.forRoot({
|
||||
global: true,
|
||||
// for http / graphql request
|
||||
middleware: {
|
||||
mount: true,
|
||||
generateId: true,
|
||||
idGenerator() {
|
||||
// make every request has a unique id to tracing
|
||||
return randomUUID();
|
||||
return `req-${randomUUID()}`;
|
||||
},
|
||||
setup(cls, _req, res: Response) {
|
||||
res.setHeader('X-Request-Id', cls.getId());
|
||||
},
|
||||
},
|
||||
// for websocket connection
|
||||
// https://papooch.github.io/nestjs-cls/considerations/compatibility#websockets
|
||||
interceptor: {
|
||||
mount: true,
|
||||
generateId: true,
|
||||
idGenerator() {
|
||||
// make every request has a unique id to tracing
|
||||
return `ws-${randomUUID()}`;
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// https://papooch.github.io/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter
|
||||
new ClsPluginTransactional({
|
||||
|
||||
Reference in New Issue
Block a user