1.0.0 • Published 10 years ago

access-watch-hapi v1.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
10 years ago

Hapi Access Watch plugin Build Status Coverage Status

Hapi Plugin for logging an analyzing web traffic using the AccessWatch service.

Installation

npm install --save access-watch-hapi 

Usage

The plugin is registered like any hapi plugin, on the server instance:

const server = new Hapi.Server();
server.register({
  register: AccessWatch,
  options: {
    // these are directly passed to access-watch-node
    apiKey: '{API-KEY}',
    // optionally pass a custom cache client here, ie
    // otherwise hapi's default is used
    cache: server.cache({
      cache: 'redis'
      expiresIn: 20 * 60 * 1000, // 20min ttl
      segment: 'accesswatch#'
    });

    // If the server runs behind a reverse proxy that sets the standard
    // forwarded headers. See the links below
    fwdHeaders: AccessWatch.fwdHeaders
  }
});

The config object is directly passed to access-watch-node. The only required parameter is apiKey. If your hapi server is behind a reverse proxy, you also need to set fwdHeaders. These are not set by default. Please see access-watch-node for details.

Debugging

To enable verbose logging pass {debug: {log: ['AccessWatch']}}

Example

See the example

Try it out by cloning this repo and run

npm install
npm install hapi
npm run example