Skip to content
Myr

Added `req.notify()` alias of `req.flash()`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 5982fa6 · Browse files · 2 files+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−2 removed

  • tests:+1 added−1 removed
  • other:+5 added−1 removed

2 files+6 added−2 removed

modified:lib/request.js+5 added-1 removed
180 unmodified lines
181182/**183 * Queue flash `msg` of the given `type`.184 *185 * This method is aliased as `req.notify()`.186 *187 * Examples:188 *189 * req.notify('info', 'email sent');190 * req.flash('info', 'email sent');191 * req.flash('error', 'email delivery failed');192 * req.flash('info', 'email re-sent');193 * // => 2
30 unmodified lines
224 * @return {Array|Object|Number}225 * @api public226 */227225req.flash = function(type, msg){228req.flash = 229req.notify = function(type, msg){230 if (this.session === undefined) throw Error('req.flash() requires sessions');231 var msgs = this.session.flash = this.session.flash || {};232233 // notification
99 unmodified lines
modified:test/request.test.js+1 added-1 removed
139 unmodified lines
140 }141 };142143 app.get('/', function(req, res){144 req.flash('info').should.be.empty;144 req.notify('info').should.be.empty;145 req.flash('error').should.be.empty;146 req.flash().should.eql({});147 req.session.flash.should.eql({});148
193 unmodified lines