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

Nest Router in V5 #8

Closed
thaoula opened this issue Apr 23, 2018 · 7 comments
Closed

Nest Router in V5 #8

thaoula opened this issue Apr 23, 2018 · 7 comments
Labels
question Further information is requested

Comments

@thaoula
Copy link

thaoula commented Apr 23, 2018

Hi @shekohex,

Do you know if the nest-router package works in V5?

We are are trying upgrade application and we are having issues in our authentication middleware.

In v4, req.path = the full relative path to an item eg /api/private/users
In v5, req.path = "/"

resolve(...excluded: Route[]): FunctionMiddleware {
return (req, res, next) => {
const isExcluded = excluded.filter(route => {
let excluedPath = route.path == req.path;
return excluedPath
}).length > 0;
}}

Not sure if this is a Nest issue or a router issue.

Regards,
Tarek

@shekohex
Copy link
Member

Hi @thaoula 😀

Actually The RouterModule Should Work as Expected with the new Version of Nest v5

I also added an example to demonstrate that it works as usual
check it here

and about your issue I also added a LoggerMiddleware that works like a charm.
see it also LoggerMiddleware

@shekohex shekohex added the question Further information is requested label Apr 24, 2018
@thaoula
Copy link
Author

thaoula commented Apr 24, 2018

Hi @shekohex,

Really appreciate getting back to me and thanks for the example.

I was getting -

image

Then I changed forRoutes("*") to forRoutes("/") like you example and now it works.

Regards,
Tarek

@shekohex
Copy link
Member

Glad it works.
Happy Coding 😄 !

@thaoula
Copy link
Author

thaoula commented Apr 24, 2018

Actually, do you mind explaining the difference between forRoutes("*") and forRoutes("/"). Our application has a number of middleware registered like this.

It would be great to understand why it worked in V4 and not V5.

@shekohex
Copy link
Member

shekohex commented Apr 24, 2018

Imo, i think because of this note

move from traditional express middleware model: each middleware is solely bounded to a particular path, regardless of the request method.

Nest Now not only supporting Express Middleware Model, Actually the design had to be changed to work well with new Adapters.
but anyway i think by just setting a global middleware in the root module. it should catch all routes, did you try this ? give it a shot.

@johnbendi
Copy link

@shekohex your Note link is broken!

@shekohex
Copy link
Member

shekohex commented Aug 4, 2018

@johnbendi
Thanks, Comment updated :)

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

No branches or pull requests

3 participants