lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.57k stars 503 forks source link

Middleware doesn't called #1173

Closed RevanthGovindan closed 2 years ago

RevanthGovindan commented 2 years ago

middleware is not getting called in controllers and methods

function Middlewares(...mws: RequestHandler[]) { return GenericMiddlewares(...mws); }

function testMiddleware(key: string) { return async (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => { console.log("middleware log"); next(); }; } @GenericMiddlewares(testMiddleware('route')) @Route("users") export class UsersController extends Controller {

@Security("api_key")
@Middlewares(testMiddleware('test1'))
@Get("UserInfo")
public async userInfo(@Request() request: any): Promise<UserResponseModel> {
    console.log(request.user)
    return Promise.resolve(request.user);
}

}

github-actions[bot] commented 2 years ago

Hello there RevanthGovindan 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

wuelcas commented 2 years ago

Hello, any news on this? I have the same problem, middleware code doesn't run at all

RevanthGovindan commented 2 years ago

@wuelcas please use the latest version (4.0.0-beta.0) of tsoa, that was the mistake i have done.

yskeat commented 2 years ago

@RevanthGovindan I'm using version 4.1.0 but it still doesn't work for me. Do you mind sharing any examples?