Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-stateless-notifications

Package Overview
Dependencies
Maintainers
20
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-stateless-notifications

A simple, explicit-state plugin to pass notices between pages.

  • 3.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
20
Weekly downloads
 
Created
Source

hapi-stateless-notifications

A plugin to give a hapi reply a reply.saveNotifications() method that collects user notifications and store them long enough to display on later pages, given the token.

Use

// step 0: set up a plugin that gives a request.redis property that's a
// client connection, ready to use for this request. We steal the
// connection from `catbox-redis`.

server.register({
    register: require('hapi-stateless-notifications'),
    options: {
        queryParameter: 'notice',
        prefix: 'notice:',
        timeout: 3600
    }
});

The options are optional.

options.queryParameter controls which query parameter will cause the plugin to look up a token and defaults to 'notice' options.prefix controls the key prefix in redis, and defaults to 'notice:' options.timeout controls the the expiration timeout of the key in redis, in seconds. The default is 3600, that is, one hour.

Then in a handler:

request.saveNotifications([
    Promise.resolve('Success message here ...'),
    Promise.reject(new Error('Error message here ...')),
]).then(function (token) {
    // if there's a token, put it in the query of the page you load next as `notice={token}`
    // Otherwise, there's nothing to do.
});

Keywords

FAQs

Package last updated on 20 Oct 2016

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