4.0.1 • Published 5 years ago

hapi-redirect v4.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage Status

Hapi redirect

A small library for redirecting requests based on http/s status code to another endpoint

Installation

npm install --save hapi-redirect

Usage

'use strict'

const Hapi = require( 'hapi' );

const server = new Hapi.Server( { port: 3000 } );

server.register( {
    plugin: require( 'hapi-redirect' ),
    options: {
        actions: [{
         status_code: 401,
         redirect: (url)=>{ return {url:'/login'}
        }]
    }
}, ( err ) => {
    // Oh no!
} );

API

hapi-redirect

hapi-redirect.plugin

  • options Object with the following keys
    • actions {array} List with redirect actions
      • status_code {string} Request status code to redirect e.g. 401 - unauthorized
      • redirect(url) {function} Function that should return { url: ..., [host:...]}
        • url Current url to be redirected from if redirect should be done or null if not

Kind: static property of hapi-redirect

Tests

npm run-script test-locally

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

4.0.1

5 years ago

4.0.0

5 years ago

3.1.0

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.7

6 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago