koa-flash2
v0.0.2
Published
Flash messages for your koa application based on connect-flash.
Downloads
3
Readme
#koa-flash2
Flash messages for koa based on connect-flash.
Installation
$ npm install koa-flash2
koa-flash2 also depends on koa-session. You must add koa-session as a middleware prior to adding koa-flash2 as seen in the example:
Example
var koa = require('koa')
, session = require('koa-session')
, flash = require('koa-flash2');
var app = koa();
app.keys = ['foo'];
app.use(session(app));
app.use(flash());
app.use(function *() {
if (this.method === 'POST') {
this.flash('error', 'This is a flash error message.');
} else if (this.method === 'GET') {
this.body = this.flash('error');
}
});
app.listen(3000);
License
MIT