New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-ding

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-ding - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.travis.yml

9

lib/index.js

@@ -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(){

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc