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

hapi-methods

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-methods - npm Package Compare versions

Comparing version 2.1.2 to 3.0.0

6

index.js

@@ -9,6 +9,6 @@ var _ = require('underscore'),

if(!method || (typeof method !== "function") || method.length < 2){
throw new Error("arguments list did not match (arg1, .... argN, callback)");
throw new Error("arguments list did not match (arg1, .... argN, next)");
}
server.method(v, function(){ /* (arg1, ...., argN, request, callback) */
server.method(v, function(){ /* (arg1, ...., argN, request, next) */
var request = arguments[arguments.length-2];

@@ -23,3 +23,3 @@ request.log(["cachemiss"], { method: v });

generateKey: function() {
var args = _.take(arguments, arguments.length-2);
var args = _.take(arguments, arguments.length-1);
var key = sha(JSON.stringify(args));

@@ -26,0 +26,0 @@

{
"name": "hapi-methods",
"version": "2.1.2",
"version": "3.0.0",
"description": "server method helper",

@@ -33,3 +33,6 @@ "main": "index.js",

"underscore": "^1.6.0"
},
"peerDependencies": {
"hapi": "^8.0.0"
}
}

@@ -1,9 +0,16 @@

Server methods helper for hapi
---
#hapi-methods
[![Build Status](https://travis-ci.org/opentable/hapi-methods.png?branch=master)](https://travis-ci.org/opentable/hapi-methods) [![NPM version](https://badge.fury.io/js/hapi-methods.png)](http://badge.fury.io/js/hapi-methods) ![Dependencies](https://david-dm.org/opentable/hapi-methods.png)
My narrow helper for server-methods, use it, or don't.
My narrow helper for server-methods, use it, or don't. Assumes that you are caching your method results.
Benefits:
- does a request.log(["cachemiss"], ...) so you can track the hit/miss ratio
- generates a sha1 key instead of stringifying the input args (useful if you have large input objects)
- what more do you need?
```
var catbox-redis = require("catbox-redis");
var server = require('hapi').createServer('127.0.0.1', 3000, {
var Hapi = require("hapi");
var server = new Hapi.Server({
cache: {

@@ -14,3 +21,6 @@ engine: require("catbox-redis"),

});
var methods = require('hapi-methods');
server.connection({ port: 3000 });
var methods = require("hapi-methods");
var config = {

@@ -17,0 +27,0 @@ expiryInSeconds: 60

@@ -51,5 +51,5 @@ var should = require('should'),

it('should register the generateKey function', function(){
var result = ms[0].c.generateKey(2, 2, request, function(err, res){});
var result = ms[0].c.generateKey(2, 2, request);
result.should.eql('251a8ad2b3294251a16936bf66f9bc747b5e9fb3');
});
});
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