1.0.0 • Published 8 years ago

harpoons v1.0.0

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
8 years ago

Harpoons

Harpoons helps you snag things - like your version number.

A simple Hapi plugin that creates a /version route that outputs your apps current package version in json format. It'll actually output any json data object you pass in - but it's mostly just for creating a version endpoint for visibility during development etc. so it doesn't output deeply nested objects.

Version npm Build Status


Installation

npm install --save harpoons

Use

Harpoons takes the following options:

  • pkg - a required json object
  • list - an optional ordered array of keys to be output from the json package - if no list is provided it defaults to display the entire package object
  • path - an optional url path - defaults to /version

Hapi Plugin

When registering Harpoons with your Hapi application ensure you pass in the relevant configuration options.

import pkg from './package.json'

// Plain registration

const options = {
    pkg,
    list: ['name', 'description', 'version']
}

server.register(require('harpoons'), options, (err) => {

    if (err) {
        console.error('Failed to load Harpoons plugin:', err);
    }
})

// Registration using Glue

registrations: [{
    plugin: {
        register: 'harpoons',
        options: {
            select: ['api'],
            pkg,
            list: ['name', 'description', 'version']
        }
    }
}]
    

// Outputs at: /version

{
    "name": "Harpoons",
    "description": "Snags the version for you",
    "version": "0.2.0"
}