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

Middleware called from another controller [BUG] #204

Open
LuisOfCourse opened this issue Dec 31, 2023 · 0 comments
Open

Middleware called from another controller [BUG] #204

LuisOfCourse opened this issue Dec 31, 2023 · 0 comments
Labels

Comments

@LuisOfCourse
Copy link

Middlewares of a controller with no path like "/" are always called even when another path is called

Considering the example at the end, If i call /test I get "meow" twice.
If you remove the middleware to the controller with no path and call /test/getTest - you'll get "meow" once.

Consider the 2 following controllers and simple middleware:

@Controller("/",[simpleMiddleware()])
export class GreetingsController {
  @Get("/getGreetings")
  async getGreetings() {
    return {"greetings":"Hello!"}
    }
}

@Controller("/test",[simpleMiddleware()])
export class TestController {
  @Get("/getTest")
  async getTest() {
    return {"test":"test"}
    }
}

export function authRefreshMiddleware() {
    return async function (req: UserRequest, res: Response, next: NextFunction) {
      console.log("meow")
    };
  }

@decorators/di: 2.0.0
@decorators/express: 2.9.4

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

No branches or pull requests

1 participant