Skip to content

travi/hapi-html-request-router

Repository files navigation

hapi-html-request-router

hapi plugin to direct html requests to a single route

Build Status

Usage

npm license

Installation

$ npm install @travi/hapi-html-request-router

Register with your Hapi v17 server

Include this plugin in the manifest of your hapi application to direct all requests for text/html to a (not included) /html route.

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.

export default {
    server: {port: process.env.PORT},
    register: {
      plugins: [
        {
          plugin: '@travi/hapi-html-request-router',
          options: [
            '/login',
            '/logout',
            '/foo/*',
            /\/bar\/.*/
          ]
        }
      ]
    }
}

Contribution

Commitizen friendly semantic-release Renovate

Install dependencies

$ nvm install
$ npm install

Verification

$ npm test

About

hapi plugin to direct html requests to a single route

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published