Socket
Socket
Sign inDemoInstall

hapi-stateless-notifications

Package Overview
Dependencies
Maintainers
1
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.


Version published
Maintainers
1
Created
Source

hapi-stateless-notifications

A plugin to give a hapi reply a reply.saveNotifications() method that collect non-fatal errors 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(require('hapi-stateless-notifications'));


Then in a handler:

request.saveNotifications([
    Promise.reject("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.
});

Any rejected promises will be collected and their error messages displayed. Successful promises (and plain values) are ignored.

V2 may separate "store these bits of text" and "collect some failed promises" but for now they're a single interface.

Keywords

FAQs

Package last updated on 31 Aug 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