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

hapi-hiredis

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-hiredis

Hapi's redis plugin

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

hapi-hiredis

Hapi (^8.0) plugin for redis with hiredis parser.

Why use this instead of simple hapi-redis?

  • hiredis parser is way faster than the plain javascript parser that comes by default with the node redis module.
  • Support for URLs. At least for me that's a major point, since I store all the data for connections in a simple URL string.

Install

npm install --save hiredis hapi-hiredis

Register plugin

You can pass as options either an URL (all are optionals, defaults to: no password, 127.0.01 and 6379) or host and port. Obviously passing an URL is way more convenient.

var Hapi = require('hapi');
var server = new Hapi.Server();

server.register({
  register: require('hapi-hiredis'),
  opts: { url: 'redis://:password@domain.tld:port' }
}, function (err) {
  if (err) console.error(err);
});

Use plugin

The object returned by redis.createClient is exposed on server.plugins['hapi-hiredis'].client and binded to the context on routes and extensions as this.redis.

server.route({
  method: 'GET',
  path: '/hashes',
  handler: function (request, reply) {
    var redis = request.server.plugins['hapi-hiredis'].client;
    redis.hgetall('hashes', function (err, obj) {
      reply(obj);
    });
  }
}, {
  method: 'GET',
  path: '/session',
  handler: function (request, reply) {
    var redis = this.redis;
    redis.get('session', function (err, obj) {
      reply(obj);
    });
  }
});

If for any reason you need to use the redis library, then you can use it from server.plugins['hapi-hiredis'].library.

License

Licensed under the terms of the ISC. A copy of the license can be found in the file LICENSE.

© 2015, Jose-Luis Rivas <me@ghostbar.co>

Keywords

FAQs

Package last updated on 23 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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