Frontexpress plugin to support Express-style path string such as /user/:name.
npm install frontexpress-path-to-regexp --save
import frontexpress from 'frontexpress';
import pathToRegexp from 'frontexpress-path-to-regexp';
// Front-end application
const app = frontexpress();
app.use(pathToRegexp);
// now all express-style path are supported :)
app.get('/:foo*', (req, res) => {
document.querySelector('.content').innerHTML = res.responseText;
});
This plugin uses path-to-regexp for matching the route paths; see the path-to-regexp documentation for all the possibilities in defining route paths. The same library used in Express.