Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Call sequence from the doc is not respected for middleware #1594

Closed
ljonathanl opened this issue Oct 20, 2021 · 1 comment · Fixed by #1597
Closed

[BUG] Call sequence from the doc is not respected for middleware #1594

ljonathanl opened this issue Oct 20, 2021 · 1 comment · Fixed by #1597

Comments

@ljonathanl
Copy link

ljonathanl commented Oct 20, 2021

Information

  • Version: 6.70.2

UseBefore Middleware on an endpoint is always called after Use middleware on the controller.

From the doc https://tsed.io/docs/middlewares.html#call-sequences, the sequence is:

MdlwCtrlBefore,
MdlwCtrlBeforeEach
MdlwBefore, (EndPoint)
MdlwCtrl,
MyCtrl.endpointA

But from my tests, MdlwBefore is called after MdlwCtrl

Example

import { Controller, Get, Middleware, Use, UseBefore } from "@tsed/common";
import { Tags } from "@tsed/schema";

@Middleware()
export class BeforeMiddleware {
  async use(): Promise<void> {
    console.log("before")
  }
}

@Middleware()
export class ControllerMiddleware {
  async use(): Promise<void> {
    console.log("controller")
  }
}

@Controller({
  path: "/test"
})
@Tags("Test")
@Use(ControllerMiddleware)
export class TestController {

  @Get("/")
  @UseBefore(BeforeMiddleware)
  async get(): Promise<void> {
    console.log("endpoint")
  }
}

I have this in the console:

controller
before
endpoint

Acceptance criteria

  • UseBefore on endpoint must be called before Use on Controller
Romakita pushed a commit to Oatelaus/tsed that referenced this issue Oct 27, 2021
@Romakita Romakita added this to To do in Global Board via automation Oct 27, 2021
@Romakita Romakita moved this from To do to Review approved in Global Board Oct 27, 2021
Romakita pushed a commit to Oatelaus/tsed that referenced this issue Oct 27, 2021
Global Board automation moved this from Review approved to Done Oct 27, 2021
@Romakita
Copy link
Collaborator

🎉 This issue has been resolved in version 6.75.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants