A lot of things, like controllers, middlewares, error handlers and so on, in RhapsodyJS revolves around the Request req and the Response res objects.

For example, a controller can have the following action:

    function(req, res) {
        res.send('One does not simply use req and res without understand them.');
    }

As their name say, the req parameter contains attributes and methods about the request made by the user, and the res parameter contains attributes and methods about the response that will be sent to the user.

Request

As RhapsodyJS uses Express inside of it, the req parameters contains all methods and attributes Express' request has natively.

Beyond this, on RhapsodyJS, req parameter also has (important: Don't forget that where the other libs' docs says that you gotta setup them, like app.use(libName()) you don't need to do that, RhapsodyJS already done it for you!) :

  • req.flash Support for flash messages, to see how it works check the documentation of the lib RhapsodyJS uses for enabling flash messages, connect-flash. Important: This will only work if you enabled sessions on your environment config file!
  • req.files If you enabled uploads on your environment config files, your request object will have this field. To see how it works, see connect-multiparty documentation.
  • req.session If you enabled session on your environment config file, you can access it in this attribute. See the express-session documentation to see how this attribute works.

Response

Like Request, Response also has all the methods and attributes natively present in the Express' response.

The res parameter also has an extra method, that can only be used inside controllers. This method is res.view, to see how it works see RhapsodyJS' controllers docs in the part about dynamic views.