@@ -44,16 +44,17 @@ describe('Class: Router - Middleware', () => {
4444 const app = new Router ( ) ;
4545 const executionOrder : string [ ] = [ ] ;
4646
47- app . use ( async ( _params , _reqCtx , next ) => {
47+ app . use ( async ( { next } ) => {
4848 executionOrder . push ( 'global-middleware' ) ;
4949 await next ( ) ;
5050 } ) ;
5151
5252 const middleware : Middleware [ ] = middlewareNames . map (
53- ( name ) => async ( _params , _reqCtx , next ) => {
54- executionOrder . push ( name ) ;
55- await next ( ) ;
56- }
53+ ( name ) =>
54+ async ( { next } ) => {
55+ executionOrder . push ( name ) ;
56+ await next ( ) ;
57+ }
5758 ) ;
5859
5960 app . get ( path as Path , middleware , async ( ) => {
@@ -137,7 +138,7 @@ describe('Class: Router - Middleware', () => {
137138 let middlewareParams : Record < string , string > | undefined ;
138139 let middlewareOptions : RequestContext | undefined ;
139140
140- app . use ( async ( params , reqCtx , next ) => {
141+ app . use ( async ( { params, reqCtx, next } ) => {
141142 middlewareParams = params ;
142143 middlewareOptions = reqCtx ;
143144 await next ( ) ;
@@ -153,15 +154,15 @@ describe('Class: Router - Middleware', () => {
153154 expect ( middlewareParams ) . toEqual ( { id : '123' } ) ;
154155 expect ( middlewareOptions ?. event ) . toBe ( testEvent ) ;
155156 expect ( middlewareOptions ?. context ) . toBe ( context ) ;
156- expect ( middlewareOptions ?. request ) . toBeInstanceOf ( Request ) ;
157+ expect ( middlewareOptions ?. req ) . toBeInstanceOf ( Request ) ;
157158 } ) ;
158159
159160 it ( 'returns error response when next() is called multiple times' , async ( ) => {
160161 // Prepare
161162 vi . stubEnv ( 'POWERTOOLS_DEV' , 'true' ) ;
162163 const app = new Router ( ) ;
163164
164- app . use ( async ( _params , _reqCtx , next ) => {
165+ app . use ( async ( { next } ) => {
165166 await next ( ) ;
166167 await next ( ) ;
167168 } ) ;
@@ -185,11 +186,11 @@ describe('Class: Router - Middleware', () => {
185186 vi . stubEnv ( 'POWERTOOLS_DEV' , 'true' ) ;
186187 const app = new Router ( ) ;
187188
188- app . use ( async ( _params , _reqCtx , next ) => {
189+ app . use ( async ( { next } ) => {
189190 await next ( ) ;
190191 } ) ;
191192
192- app . use ( async ( _params , _reqCtx , next ) => {
193+ app . use ( async ( { next } ) => {
193194 next ( ) ;
194195 } ) ;
195196
@@ -241,7 +242,7 @@ describe('Class: Router - Middleware', () => {
241242 const app = new Router ( ) ;
242243 const executionOrder : string [ ] = [ ] ;
243244
244- app . use ( async ( _params , _reqCtx , next ) => {
245+ app . use ( async ( { next } ) => {
245246 executionOrder . push ( 'middleware1-start' ) ;
246247 await next ( ) ;
247248 executionOrder . push ( 'middleware1-end' ) ;
@@ -362,7 +363,7 @@ describe('Class: Router - Middleware', () => {
362363 // Prepare
363364 const app = new Router ( ) ;
364365
365- app . use ( async ( _params , reqCtx , next ) => {
366+ app . use ( async ( { reqCtx, next } ) => {
366367 await next ( ) ;
367368 reqCtx . res . headers . set ( 'x-custom-header' , 'middleware-value' ) ;
368369 reqCtx . res . headers . set ( 'x-request-id' , '12345' ) ;
@@ -393,7 +394,7 @@ describe('Class: Router - Middleware', () => {
393394 // Prepare
394395 const app = new Router ( ) ;
395396
396- app . use ( async ( _params , reqCtx , next ) => {
397+ app . use ( async ( { reqCtx, next } ) => {
397398 await next ( ) ;
398399 const originalBody = await reqCtx . res . text ( ) ;
399400 reqCtx . res = new Response ( `Modified: ${ originalBody } ` , {
@@ -422,7 +423,7 @@ describe('Class: Router - Middleware', () => {
422423 // Prepare
423424 const app = new Router ( ) ;
424425
425- app . use ( async ( _params , reqCtx , next ) => {
426+ app . use ( async ( { reqCtx, next } ) => {
426427 reqCtx . res . headers . set ( 'x-before-handler' , 'middleware-value' ) ;
427428 await next ( ) ;
428429 } ) ;
@@ -451,7 +452,7 @@ describe('Class: Router - Middleware', () => {
451452 // Prepare
452453 const app = new Router ( ) ;
453454
454- app . use ( async ( _params , reqCtx , next ) => {
455+ app . use ( async ( { reqCtx, next } ) => {
455456 reqCtx . res . headers . set ( 'x-before-handler' , 'middleware-value' ) ;
456457 await next ( ) ;
457458 } ) ;
@@ -478,12 +479,12 @@ describe('Class: Router - Middleware', () => {
478479 // Prepare
479480 const app = new Router ( ) ;
480481
481- app . use ( async ( _params , reqCtx , next ) => {
482+ app . use ( async ( { reqCtx, next } ) => {
482483 reqCtx . res . headers . set ( 'x-test-header' , 'before-next' ) ;
483484 await next ( ) ;
484485 } ) ;
485486
486- app . use ( async ( _params , reqCtx , next ) => {
487+ app . use ( async ( { reqCtx, next } ) => {
487488 await next ( ) ;
488489 reqCtx . res . headers . set ( 'x-test-header' , 'after-next' ) ;
489490 } ) ;
@@ -531,7 +532,7 @@ describe('Class: Router - Middleware', () => {
531532 const app = new Router ( ) ;
532533 const executionOrder : string [ ] = [ ] ;
533534
534- app . use ( async ( _params , _reqCtx , next ) => {
535+ app . use ( async ( { next } ) => {
535536 executionOrder . push ( 'middleware-start' ) ;
536537 await next ( ) ;
537538 executionOrder . push ( 'middleware-end' ) ;
0 commit comments