Skip to content

fix: create controllers in specified order #774

Open
@getfatday

Description

@getfatday

Description

Controllers are created in the order they are registered with metadata, not in the order they are passed into the router controller options.

@Controller()
class ThirdController {
  @Get('/*')
  getAll() {
    return 'Third';
  }
}

@Controller()
class SecondController {
  @Get('/second/*')
  getAll() {
    return 'Second';
  }
}

@Controller()
class FirstController {
  @Get('/second/first/*')
  getAll() {
    return 'First';
  }
}

createExpressServer({
  controllers: [FirstController, SecondController, ThirdController],
})

Expected behavior

Requests are handle by the First controller, which is the first in the controller order, but last to be registered.

GET /second/first/any

First

Actual behavior

Requests are handle by the Third controller, which is the last in the controller order, but first to be registered.

GET /second/first/any

Third

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions