0.1.3 • Published 9 years ago

simple-flash v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

simple-flash

Simple Flash is a very simple way to set flash messages in Express routes.

Installation

npm install simple-flash

Usage

In your app.js (after session setup line):

var flash = require('simple-flash');
app.use(flash());

In your route, only add your messages using the new funcion req.flash(type,message):

app.post('/foo', function(req, res){
    try {
        // your awesom code here
        req.flash('success','Your success message here!');
        res.redirect('/bar');
    } catch (e){
        req.flash('error','Your error message here!');
        res.redirect('/foo');
    }
})

For render messages in view, simpliest use the new local function flash() to return messages array.

Jade example:

for message in flash()
	.row
		.col-xs-12
			div(class="alert alert-#{message.type}") #{message.message}

Or:

- flash().forEach(function(message){
	.row
		.col-xs-12
			div(class="alert alert-#{message.type}") #{message.message}
- })

For development and tests:

git clone https://github.com/thiagobs/simple-flash.git && cd simple-flash
npm install

Run tests:

npm test

License

MIT License

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago