@box-maker/hapi-route-logging

0.2.0 • Public • Published

hapi-route-logging

A simple plugin to print on screen the routes consulted, ideal during development.

Travis CI Greenkeeper Coveralls Version Node Minimum version XO code style

Introduction

Those who have tried other backend frameworks like Django or Flask will have noticed that when you run the development server, this shows information about each request made. This plugin tries to imitate this simple functionality, it does this by displaying a brief start at the beginning with basic information and then showing information is brief but useful on every request.

Basic capture

Install

Requirements

This plugin has been tested to work with Node in version 4.8.0 and higher, there's no guarantee of performance or support on lower versions.

This plugin is tested with the latest version of Hapi.js

For installation use the Node Package Manager (npm) or Yarn

With npm:

From npm directory:

$ npm install -D @box-maker/hapi-route-logging

From source

WARNING: May be unstable, but includes all changes made

$ npm install git+https://github.com/box-maker/hapi-route-logging.git

With yarn:

From npm directory:

$ yarn add -D @box-maker/hapi-route-logging

From source

WARNING: May be unstable, but includes all changes made

$ yarn add https://github.com/box-maker/hapi-route-logging.git

Usage

You can find complete examples inside the examples directory, both using require and import

Import

Using require

const hapiRouteLogging = require('@box-maker/hapi-route-logging');

Using import (Requires Babel)

import hapiRouteLogging from '@box-maker/hapi-route-logging';

Registration

Without options

server.register(hapiRouteLogging, err => {
  if (err) {
    throw err;
  }
});

With options

server.register({
  register: hapiRouteLogging,
  options: {
    showRoutes: true
  }
}, err => {
  if (err) {
    throw err;
  }
});

Loading multiple plugins

server.register([
  {
    register: hapiRouteLogging,
    options: {
      showRoutes: false,
      showRoutesList: true
    }
  },
  {
    register: otherPlugin,
    options: {}
  }
], err => {
  if (err) {
    throw err;
  }
});

Options

The following options are available:

showRoutes (Default: Enable)

Enables the displayed information on the routes consulted

showRoutesList (Default: Disabled)

This display the routes table to console at startup

checkUpgrade (Default: Disabled)

Verify that the latest version of Hapi is being used

Development

Dependencies
David
David

First you have to install all dependencies:

yarn install

or

npm install

To execute all unit tests once, use:

$ npm test

or to run tests based on file watcher, use:

$ npm start

To get information about the test coverage, use:

$ npm run coverage

Contribution

Fork this repository and push in your ideas.

Do not forget to add corresponding tests to keep up 100% test coverage.

License

This plugin is licensed under the Mozilla Public License Version 2.0, you can find a copy of this in the file LICENSE. Please respect the same.

Package Sidebar

Install

npm i @box-maker/hapi-route-logging

Weekly Downloads

2

Version

0.2.0

License

MPL-2.0

Last publish

Collaborators

  • eliluminado