0.0.4 • Published 11 years ago

flash-messages v0.0.4

Weekly downloads
61
License
-
Repository
github
Last release
11 years ago

flash-messages

Flash messages support to use with ExpressJs.

Install

npm install flash-messages

Loading

var FlashMessages = require('flash-messages');

Configuration

FlashMessages.configure(options);

Options

Configuration is not mandatory but allows to specify if the module should activate the debug and verbose mode as well as the field name in the locals to contain the flash messages. Default configuration is debug: false, verbose: false and fieldName: flash.

eg

Initianlisation

The initialisation has to be done after the session activation in express application.

app.use(FlashMessages.init);

Usage

The method flash is added to the express request object. this method if no parameter is given, list all the messages present in the flash messages.

If a string parameter is given, it retrieves the message with the key equals to the string argument, and if the message has a scope equal to REQUEST_SCOPE then the message is removed from the flash messages.

If the method is called with one object argument or an array of object as argument, a message or a list of messages are created and stored in the flash messages. These objects have to declare a key, and a value. They can also declare a scope: FlashMessages.REQUEST_SCOPE / FlashMessages.SESSION_SCOPE. By default the REQUEST_SCOPE scope is set and force the message to be pull out of the flash messages if requested. The SESSION_SCOPE scope mode keeps the message in the flash messages until the session is deleted; this message can be updated by adding a new message with the same key to the flash messages.

If you pass 2 or 3 arguments then a message will be created with for key the first argument, for value the second one and for scope the third (not mandatory) one.

Support

it-tweaks

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago