Comparing version 0.1.1 to 0.1.2
@@ -10,3 +10,4 @@ 'use strict'; | ||
path: '/ding', | ||
objectName: 'ding' | ||
objectName: 'ding', | ||
config: { auth: false } | ||
}, | ||
@@ -16,2 +17,3 @@ options: Joi.object({ | ||
objectName: Joi.string().optional().allow(null, false), | ||
config: Joi.object().optional(), | ||
otherData: Joi.object().optional() | ||
@@ -33,3 +35,3 @@ }) | ||
path: settings.path, | ||
config: { auth: false }, | ||
config: settings.config, | ||
handler: function(req, reply) { | ||
@@ -42,3 +44,3 @@ var res = { | ||
if(req.server.settings.load && req.server.settings.load.sampleInterval) { | ||
if(req.server.settings.load.sampleInterval) { | ||
res.heap = req.server.load.heapUsed; | ||
@@ -61,2 +63,3 @@ res.loop = req.server.load.eventLoopDelay; | ||
}); | ||
next(); | ||
@@ -63,0 +66,0 @@ }; |
{ | ||
"name": "hapi-ding", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Informational status page for Hapi apps", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "lab -r console -t 100 -a code" | ||
"test": "lab -r console -t 100 -a code", | ||
"test-ci": "lab -r lcov -t 100 -a code | ./node_modules/.bin/coveralls" | ||
}, | ||
@@ -14,9 +15,10 @@ "repository": "git://github.com/dialexa/hapi-ding", | ||
"hoek": "^2.11.1", | ||
"joi": "^6.0.3", | ||
"hapi": ">=8" | ||
"joi": "^6.0.8" | ||
}, | ||
"devDependencies": { | ||
"code": "^1.3.0", | ||
"lab": "^5.4.0" | ||
"coveralls": "^2.11.2", | ||
"hapi": "^8.4.0", | ||
"lab": "^5.5.0" | ||
} | ||
} |
Ding Route Plugin for Hapi | ||
========================== | ||
[![NPM](https://nodei.co/npm/hapi-ding.png)](https://nodei.co/npm/hapi-ding/) | ||
[![npm version](https://badge.fury.io/js/hapi-ding.svg)](http://badge.fury.io/js/hapi-ding) | ||
[![Build Status](https://travis-ci.org/dialexa/hapi-ding.svg)](https://travis-ci.org/dialexa/hapi-ding) | ||
[![Coverage Status](https://coveralls.io/repos/dialexa/hapi-ding/badge.svg?branch=master)](https://coveralls.io/r/dialexa/hapi-ding?branch=master) | ||
@@ -50,1 +49,7 @@ This Hapi plugin exposes a route at /ding (by default), which responds with useful server information. | ||
## Plugin Options | ||
The following options are available when registering the plugin: | ||
- _'path'_ - the path where the route will be registered. Default is /ding. | ||
- _'objectName'_ - the name of the object returned. Can be a string or `false` to put the properties at the root level. Defaults to "ding". | ||
- _'config'_ - optional [Hapi route options](http://hapijs.com/api#route-options) to be merged with the defaults. Defaults to `{ auth: false }`. | ||
- _'otherData'_ - static object to be merged with the info object. Defaults to `null`. |
@@ -44,2 +44,10 @@ var Lab = require('lab'); | ||
it('should let you set config options', function(done){ | ||
server.register({register: require('../'), options: {config: {description: 'Custom Hapi Ding'}}}, function() { | ||
var routes = server.table(); | ||
expect(routes[0].table[0].settings.description).to.equal('Custom Hapi Ding'); | ||
done(); | ||
}); | ||
}); | ||
it('should not let you set unknown options', function(done){ | ||
@@ -91,46 +99,48 @@ server.register({register: require('../'), options: {badName: {foo: 'bar'}}}, function(err) { | ||
// describe('Hapi load reporting', function(){ | ||
// it('should reply with heap', function(done){ | ||
// var server = new Hapi.Server({load: { sampleInterval: 1000 }}); | ||
// var con = server.connection({ host: 'test' }); | ||
describe('Hapi load reporting', function(){ | ||
it('should reply with heap', function(done){ | ||
var server = new Hapi.Server({load: { sampleInterval: 1000 }}).connection({ host: 'test' }); | ||
// con.register({register: require('../')}, function() { | ||
// server.start(function(){ | ||
// con.inject('/ding', function(res){ | ||
// expect(res.result.ding).to.be.an.object(); | ||
// expect(res.result.ding.heap).to.be.a.number(); | ||
// server.stop(done); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
server.register({register: require('../')}, function() { | ||
server.connections[0]._load._process.load.heapUsed = 100000; | ||
server.connections[0]._load.check = function(){ return false; }; | ||
server.inject('/ding', function(res){ | ||
expect(res.result.ding).to.be.an.object(); | ||
expect(res.result.ding.heap).to.be.a.number(); | ||
expect(res.result.ding.heap).to.equal(100000); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
// it('should reply with loop', function(done){ | ||
// var server = new Hapi.Server({load: { sampleInterval: 1000 }}); | ||
// server.connection({ host: 'test' }); | ||
it('should reply with heap', function(done){ | ||
var server = new Hapi.Server({load: { sampleInterval: 1000 }}).connection({ host: 'test' }); | ||
// server.register({register: require('../')}, function() { | ||
// server.start(function(){ | ||
// server.inject('/ding', function(res){ | ||
// expect(res.result.ding).to.be.an.object(); | ||
// expect(res.result.ding.loop).to.be.a.number(); | ||
// server.stop(done); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
server.register({register: require('../')}, function() { | ||
server.connections[0]._load._process.load.eventLoopDelay = 1.34; | ||
server.connections[0]._load.check = function(){ return false; }; | ||
server.inject('/ding', function(res){ | ||
expect(res.result.ding).to.be.an.object(); | ||
expect(res.result.ding.loop).to.be.a.number(); | ||
expect(res.result.ding.loop).to.equal(1.34); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
// it('should not reply with heap or loop if the server does not have ', function(done){ | ||
// var server = new Hapi.Server().connection({ host: 'test' }); | ||
it('should not reply with heap or loop if the server does not have the load settings', function(done){ | ||
var server = new Hapi.Server().connection({ host: 'test' }); | ||
// server.register({register: require('../')}, function() { | ||
// server.inject('/ding', function(res){ | ||
// expect(res.result.ding).to.be.an.object(); | ||
// expect(res.result.ding.loop).to.be.undefined(); | ||
// expect(res.result.ding.heap).to.be.undefined(); | ||
// done(); | ||
// }); | ||
// }); | ||
// }); | ||
// }); | ||
server.register({register: require('../')}, function() { | ||
server.connections[0]._load._process.load.eventLoopDelay = 1.34; | ||
server.connections[0]._load.check = function(){ return false; }; | ||
server.inject('/ding', function(res){ | ||
expect(res.result.ding).to.be.an.object(); | ||
expect(res.result.ding.loop).to.be.undefined(); | ||
expect(res.result.ding.heap).to.be.undefined(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -137,0 +147,0 @@ describe('Custom /ding response', function(){ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10033
2
8
212
55
4
1
- Removedhapi@>=8
- Removedaccept@3.1.3(transitive)
- Removedammo@3.0.3(transitive)
- Removedb64@4.1.2(transitive)
- Removedboom@7.3.0(transitive)
- Removedbounce@1.2.3(transitive)
- Removedbourne@1.3.3(transitive)
- Removedcall@5.0.3(transitive)
- Removedcatbox@10.0.6(transitive)
- Removedcatbox-memory@4.0.1(transitive)
- Removedcontent@4.0.6(transitive)
- Removedcryptiles@4.1.3(transitive)
- Removedhapi@18.1.0(transitive)
- Removedheavy@6.1.2(transitive)
- Removedhoek@6.1.3(transitive)
- Removediron@5.0.6(transitive)
- Removedisemail@3.2.0(transitive)
- Removedjoi@14.3.1(transitive)
- Removedmime-db@1.53.0(transitive)
- Removedmimos@4.0.2(transitive)
- Removednigel@3.0.4(transitive)
- Removedpez@4.0.5(transitive)
- Removedpodium@3.2.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedshot@4.0.7(transitive)
- Removedsomever@2.0.0(transitive)
- Removedstatehood@6.0.9(transitive)
- Removedsubtext@6.0.12(transitive)
- Removedteamwork@3.2.0(transitive)
- Removedtopo@3.0.3(transitive)
- Removedvise@3.0.2(transitive)
- Removedwreck@14.2.0(transitive)
Updatedjoi@^6.0.8