Skip to content

Commit

Permalink
fix(prod-server): inject reporter from req (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiveMe-A-Name authored Nov 6, 2023
1 parent 95f15d2 commit a68a2e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/unlucky-adults-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/prod-server': patch
---

fix(prod-server): inject reporter from req
fix(prod-server): 从 req 里拿到 reporter 去注入
3 changes: 3 additions & 0 deletions packages/server/prod-server/src/libs/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class ModernServerContext implements ModernServerContextInterface {
this.res,
cutNameByHyphen(options?.metaName || 'modern-js'),
);

// inject reporter from req if it has.
req.reporter && (this.reporter = req.reporter);
}

private get parsedURL() {
Expand Down
2 changes: 2 additions & 0 deletions packages/server/prod-server/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import type {
NextFunction,
ModernServerContext,
InternalPlugins,
Reporter,
} from '@modern-js/types';
import type { ModernRouteInterface } from './libs/route';

declare module 'http' {
interface IncomingMessage {
logger: Logger;
metrics: Metrics;
reporter?: Reporter;
body?: any;
}

Expand Down

0 comments on commit a68a2e9

Please sign in to comment.