Hi,
I’m using RadSystems Studio 9.2.0 to generate a Node.js backend.
According to the release notes, this version uses Express 5, but the generated controllers still contain route definitions that are compatible with Express 4 only, for example:
router.get(['/', '/index/:fieldname?/:fieldvalue?'], async (req, res) => {
This syntax uses optional parameters (?), which are no longer supported in Express 5 (due to changes in path-to-regexp).
As a result, the application crashes at startup with an error like:
PathError [TypeError]: Unexpected ? at index ...
To make it work, I have to manually rewrite the routes like this:
router.get('/', handler);
router.get('/index', handler);
router.get('/index/:fieldname', handler);
router.get('/index/:fieldname/:fieldvalue', handler);
So it seems there is a mismatch between:
-
the Express version used (v5)
-
and the route syntax generated by templates (Express 4 style)
Suggestion
It would be great if:
-
templates are updated to generate Express 5 compatible routes
-
or an option is provided to select Express 4 vs Express 5 compatibility
Thanks!