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
Subapps are not mounted #16
Conversation
Thanks for the bug report and thorough example! Yes, I see, you're right. I'm not sure off the top of my head what would cause this to not work, but I need to take a detailed look at Express 4 in general. Express http://expressjs.com/4x/api.html#app.use So the assumptions express-streamline makes should be valid. But in case they're not, I have a hunch that the issue is somewhere here: https://github.com/aseemk/express-streamline/blob/0.5.0/index.js#L111-L118 If that's the case, one thing you could try as a workaround for now is to pass a second function to your Does that fix it for you? If so, that'd be a clue for fixing this issue at the root. Thanks again for the report and thorough example! When I get to this, I'll make a test case from it. |
add workaround for aseemk/express-streamline#16
I just started using Express which makes it hard for me to follow your explanation. 👽
My current workaround is to manually set the mountpath... 😃 |
I simplified the example apps a bit and made it (not) work for Express 3. Same issue there. |
Oh, nice — didn't realize even that simple workaround was possible. Great to hear. =) And sweet, thanks for the repro on Express 3 too. That's helpful. |
add workaround for aseemk/express-streamline#16
I think I understand the problem now but I don't know how to fix it: For
the condition at this point is |
How about adding the "Am I an Express app"-condition ( |
Oh wow, I missed that this was a pull request and not an issue. Thanks for submitting! I don't have time right now to review and test it, but I hope to soon! |
Actually, I see that this is pretty straightforward. Nice work! It generally LGTM if we can confirm that the tests pass across all versions of Express. To that end, could you rebase this to the latest master so we know? # add this repo as an upstream remote:
git remote add upstream https://github.com/aseemk/express-streamline.git
# on your branch, rebase to the current upstream master;
# you can optionally choose to squash some commits together:
git rebase --interactive upstream/master
# ensure that tests still pass, i.e. something didn't break:
npm test
# if at any point, you feel something broke, you can always abort via:
# git rebase --abort
# assuming everything is good, push the latest;
# the `+` is required since this has "rewritten" your branch's history;
# this also assumes your fork's remote is named `origin`:
git push origin +head:patch-1 If any of this is too complex or daunting for you, no worries at all. Just let me know and I'd be happy to test this myself. Thank you again! |
} | ||
|
||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: let's move this helper function out of patch()
, since it doesn't need to be re-defined for every verb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- done
Prevent `patch` function from wrapping Express apps because they are otherwise no longer recognized by Express as such.
@aseemk Thank you for the review and all the helpful comments! All makes sense to me and I changed it. For all my forks I actually have two remotes, so it was basically a I pushed the changes in two steps such that there are two builds confirming that the patch targets the issue: P.S. I recently learned that you can convert issues to pull requests... maybe that explains where this pull request suddenly came from 😀 Unfortunately, you can't change the branch (name) of a pull request afterwards. |
Excellent work! Thank you for the thoroughness and attention to detail. =) Merging! P.S. Ah, got it! Thanks for explaining. =D |
When I access
req.app.mountpath
in the Router of a subapp, the behavior is different than from without streamline.Without express-streamline I get
but with streamline I get
Edit by @aseemk: diff between branches