-
Notifications
You must be signed in to change notification settings - Fork 368
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
How to use newer versions with express? #66
Comments
I don't think so, but cc @dougwilson There's some things in |
Yes, in the current router, there is not a simple way to use an updated version of |
How can I use the latest version path-to-regexp with express 4? |
Is this the right way? import * as pathRegexp from "path-to-regexp" // v1.5.3
// for path "/signup:phone"
router.post(pathRegexp("/signup\\:phone"), wrap(async (req, res) => {
return res.json({ success: true, message: "Success!"})
})) |
@frogcjn As mentioned, it's not really possible. You can use the output of |
Ultimately, it seems that the keys need to go into the regexp's "keys" property, but that is being overwritten with numeric keys. So you could use defineProperty to make it have the correct value and be readonly (with setter to silently ignore updates, not throw an exception) before you pass it to express's .use .post .get etc. |
I think it might be a good idea to change regexpToRegexp to respect any existing keys property instead of overwriting it. It could even be backported to an old path-to-regexp version that express can use, but will be a good feature without that too. |
Closing as resolved |
Express 4.13.3 seems to depend on old path-to-regexp version 0.1.7
A lot of cool things that work in the express route tester turn out to not actually work in express, and I assume it is because of the version difference.
Is there a recommended way to get express to use the new versions, or should I just hack its package.json, or what?
The text was updated successfully, but these errors were encountered: