22import { Integration , Transaction } from '@sentry/types' ;
33import { logger } from '@sentry/utils' ;
44
5- // Have to manually set types because we are using package-alias
65type Method =
76 | 'all'
87 | 'get'
@@ -30,7 +29,7 @@ type Method =
3029 | 'unsubscribe'
3130 | 'use' ;
3231
33- type Application = {
32+ type Router = {
3433 [ method in Method ] : ( ...args : any ) => any ;
3534} ;
3635
@@ -80,13 +79,13 @@ export class Express implements Integration {
8079 /**
8180 * Express App instance
8281 */
83- private readonly _app ?: Application ;
82+ private readonly _app ?: Router ;
8483 private readonly _methods ?: Method [ ] ;
8584
8685 /**
8786 * @inheritDoc
8887 */
89- public constructor ( options : { app ?: Application ; methods ?: Method [ ] } = { } ) {
88+ public constructor ( options : { app ?: Router ; methods ?: Method [ ] } = { } ) {
9089 this . _app = options . app ;
9190 this . _methods = ( Array . isArray ( options . methods ) ? options . methods : [ ] ) . concat ( 'use' ) ;
9291 }
@@ -224,7 +223,7 @@ function wrapMiddlewareArgs(args: unknown[], method: Method): unknown[] {
224223/**
225224 * Patches original App to utilize our tracing functionality
226225 */
227- function patchMiddleware ( app : Application , method : Method ) : Application {
226+ function patchMiddleware ( app : Router , method : Method ) : Router {
228227 const originalAppCallback = app [ method ] ;
229228
230229 app [ method ] = function ( ...args : unknown [ ] ) : any {
@@ -237,7 +236,7 @@ function patchMiddleware(app: Application, method: Method): Application {
237236/**
238237 * Patches original application methods
239238 */
240- function instrumentMiddlewares ( app : Application , methods : Method [ ] = [ ] ) : void {
239+ function instrumentMiddlewares ( app : Router , methods : Method [ ] = [ ] ) : void {
241240 methods . forEach ( ( method : Method ) => patchMiddleware ( app , method ) ) ;
242241}
243242
0 commit comments