Skip to content

camelaissani/frontexpress-path-to-regexp

Repository files navigation

frontexpress-path-to-regexp

Frontexpress plugin to support Express-style path string such as /user/:name.

Build Status Code Climate Coverage Status Size Shield

Installation

npm install frontexpress-path-to-regexp --save

Usage

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.