Only call req.flash() when it is a defined function

When using certain frameworks (e.g. CompoundJS), req.flash is not a function, which causes the below error:

TypeError: Object #<IncomingMessage> has no method 'flash'

This pull request detects if req.flash() is indeed a function. If it is, it uses that default functionality; otherwise, it sets a session variable which Compound uses in rendering flash messages.