UNPKG

439 Btext/coffeescriptView Raw
1isFunction = (obj) -> '[object Function]' is toString.call obj
2
3module.exports = (message, type = 'info') -> (req, res, next) ->
4 throw new Error 'missing session middleware' unless req?.session?
5 throw new Error "next is not a function #{next}" unless isFunction next
6 msg = message
7 msg = msg req if isFunction msg
8 console.log 'flash', type, msg
9 req.session.flash =
10 message: msg
11 type: type
12 next()