@travi/hapi-html-request-router
Version:
hapi plugin to direct html requests to a single route
80 lines (60 loc) • 2.08 kB
Markdown
# hapi-html-request-router
[hapi](https://hapijs.com) plugin to direct html requests to a single route
[](https://travis-ci.com/travi/hapi-html-request-router)
## Usage
[](https://www.npmjs.com/package/@travi/hapi-html-request-router)
[](LICENSE)
### Installation
```sh
$ npm install @travi/hapi-html-request-router
```
### Register with your [Hapi](https://hapijs.com) v17 server
Include this plugin in the [manifest](https://github.com/hapijs/glue) of your
hapi application to direct all requests for `text/html` to a
([not included](https://github.com/travi/hapi-react-router)) `/html` route.
```js
export default {
server: {port: process.env.PORT},
register: {
plugins: [
{plugin: '@travi/hapi-html-request-router'}
]
}
}
```
### Options
#### `excludedRoutes`
Sometimes you don't want all routes to be re-routed to the `/html` route.
Provide a list of routes as strings or regex patterns to exclude them from
being re-routed.
```js
export default {
server: {port: process.env.PORT},
register: {
plugins: [
{
plugin: '@travi/hapi-html-request-router',
options: [
'/login',
'/logout',
'/foo/*',
/\/bar\/.*/
]
}
]
}
}
```
## Contribution
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/semantic-release/semantic-release)
[](https://greenkeeper.io/)
### Install dependencies
```sh
$ nvm install
$ npm install
```
### Verification
```sh
$ npm test
```