hapi-methods
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -11,6 +11,6 @@ var _ = require('underscore'), | ||
} | ||
server.method(v, function(){ /* (arg1, ...., argN, request, callback) */ | ||
var request = arguments[arguments.length-2]; | ||
request.log(["cachemiss"], { method: v }); | ||
request.log(["cachemiss"], { method: v }); | ||
@@ -23,5 +23,7 @@ var args = _.take(arguments, arguments.length-2); | ||
generateKey: function() { | ||
var request = arguments[arguments.length-2]; | ||
var args = _.take(arguments, arguments.length-2); | ||
var key = sha(JSON.stringify(args)); | ||
server.log(["key-generate"], JSON.stringify(args) + " => " + key); | ||
request.log(["key-generate"], { args: args, key: key }); | ||
return key; | ||
@@ -28,0 +30,0 @@ } |
{ | ||
"name": "hapi-methods", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "server method helper", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,5 +14,2 @@ var should = require('should'), | ||
ms.push({ m: m, c: c }); | ||
}, | ||
log: function(t, v){ | ||
serverlogs.push(v); | ||
} | ||
@@ -35,3 +32,3 @@ }, | ||
}); | ||
it('should throw an error when the method signature is invalid', function(){ | ||
@@ -60,8 +57,7 @@ helper.register.bind(null, server, cache, { myMethod: function(){} }).should.throw(); | ||
it('should log the key and args when invoked', function(){ | ||
it('should log the key and args when generating cache key', function(){ | ||
ms[0].c.generateKey(2, 2, request, function(err, res){}); | ||
var bits = serverlogs[0].split(" => "); | ||
bits[1].should.eql('251a8ad2b3294251a16936bf66f9bc747b5e9fb3'); | ||
bits[0].should.eql(JSON.stringify([2, 2])); | ||
logs[1].key.should.eql('251a8ad2b3294251a16936bf66f9bc747b5e9fb3'); | ||
logs[1].args.should.eql([2, 2]); | ||
}); | ||
}); |
9393
192