Skip to content

Commit

Permalink
fix(http): remove TagRegistry dep and fix middleware tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Oct 1, 2023
1 parent 4f1dd35 commit 7fa50d8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,14 @@ export class HttpListener {

async function next() {
i++;
const timeout = middlewares[i].timeout;

if (i >= middlewares.length) {
event.response.off('finish', finish);
resolve(undefined);
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})`);
Expand Down
4 changes: 1 addition & 3 deletions packages/http/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -561,14 +560,13 @@ export class HttpRouter {

static forControllers(
controllers: (ClassType | { module: InjectorModule<any>, controller: ClassType })[],
tagRegistry: TagRegistry = new TagRegistry(),
middlewareRegistry: MiddlewareRegistry = new MiddlewareRegistry(),
module: InjectorModule<any> = 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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/http/tests/middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7fa50d8

Please sign in to comment.