diff --git a/packages/http/src/http.ts b/packages/http/src/http.ts index d566814f3..3c65952fb 100644 --- a/packages/http/src/http.ts +++ b/packages/http/src/http.ts @@ -591,7 +591,6 @@ export class HttpListener { async function next() { i++; - const timeout = middlewares[i].timeout; if (i >= middlewares.length) { event.response.off('finish', finish); @@ -599,6 +598,7 @@ export class HttpListener { return; } + const timeout = middlewares[i].timeout; if (timeout !== undefined && timeout > 0) { lastTimer = setTimeout(() => { logger.warning(`Middleware timed out. Increase the timeout or fix the middleware. (${middlewares[i].fn})`); diff --git a/packages/http/src/router.ts b/packages/http/src/router.ts index 0c9177106..0427f31c7 100644 --- a/packages/http/src/router.ts +++ b/packages/http/src/router.ts @@ -545,7 +545,6 @@ export class HttpRouter { constructor( controllers: HttpControllers, private logger: LoggerInterface, - tagRegistry: TagRegistry, private config: HttpConfig, private middlewareRegistry: MiddlewareRegistry = new MiddlewareRegistry, private registry: HttpRouterRegistry = new HttpRouterRegistry, @@ -561,14 +560,13 @@ export class HttpRouter { static forControllers( controllers: (ClassType | { module: InjectorModule, controller: ClassType })[], - tagRegistry: TagRegistry = new TagRegistry(), middlewareRegistry: MiddlewareRegistry = new MiddlewareRegistry(), module: InjectorModule = new InjectorModule(), config: HttpConfig = new HttpConfig() ): HttpRouter { return new this(new HttpControllers(controllers.map(v => { return isClass(v) ? { controller: v, module } : v; - })), new Logger([], []), tagRegistry, config, middlewareRegistry); + })), new Logger([], []), config, middlewareRegistry); } protected getRouteCode(compiler: CompilerContext, routeConfig: RouteConfig): string { diff --git a/packages/http/tests/middleware.spec.ts b/packages/http/tests/middleware.spec.ts index ac9cab3c3..0e2425439 100644 --- a/packages/http/tests/middleware.spec.ts +++ b/packages/http/tests/middleware.spec.ts @@ -16,7 +16,7 @@ class Controller { test('middleware empty', async () => { const httpKernel = createHttpKernel([Controller], [], [], [httpMiddleware.for((req, res, next) => { next(); - })]); + }).timeout(100)]); const response = await httpKernel.request(HttpRequest.GET('/user/name1')); expect(response.statusCode).toEqual(200);