harpoons
v1.0.0
Published
Snags the version for you
Downloads
5
Readme
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.
Installation
npm install --save harpoons
Use
Harpoons takes the following options:
pkg
- a required json objectlist
- 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 objectpath
- 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"
}