Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/humble-flash
Flash message plugin for humble-session and hapi.
https://github.com/zkochan/humble-flash
Last synced: 10 days ago
JSON representation
Flash message plugin for humble-session and hapi.
- Host: GitHub
- URL: https://github.com/zkochan/humble-flash
- Owner: zkochan
- License: mit
- Created: 2015-10-29T21:21:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T19:50:13.000Z (about 8 years ago)
- Last Synced: 2024-11-25T08:40:48.439Z (28 days ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# humble-flash
Flash message plugin for [humble-session](https://github.com/zkochan/humble-session) and [hapi](http://hapijs.com/).
[![Dependency Status](https://david-dm.org/zkochan/humble-flash/status.svg?style=flat)](https://david-dm.org/zkochan/humble-flash)
[![Build Status](https://travis-ci.org/zkochan/humble-flash.svg?branch=master)](https://travis-ci.org/zkochan/humble-flash)
[![npm version](https://badge.fury.io/js/humble-flash.svg)](http://badge.fury.io/js/humble-flash)## Installation
```
npm i --save humble-flash
```## Usage
**Note.** This module requires [humble-session](https://github.com/zkochan/humble-session) to be
registered as well.**TODO: write usage example**
## API
* [`reply.flash`](#flash)
* [`createPreHandler`](#createPreHandler)
### reply.flash(type, message, cb)Adds a new flash message of a specified type to the session.
__Arguments__
`type` - String - The type of the flash message.
`message` - String - The text of the message.
`cb(err)` - Function - A function that is called once the flash message was saved
to the session.Creates a pre-handler that fetches the messages of the specified type from the
session and removes them from it.__Arguments__
`type` - String - The type of the messages to return.
__Usage__
```js
var humbleFlash = require('humble-flash');// ...
server.route({
method: 'GET',
path: '/',
config: {
pre: [humbleFlash.createPreHandler('info')]
},
handler: function(request, reply) {
reply(request.pre.info);
}
});
```## License
MIT © [Zoltan Kochan](https://www.kochan.io)