Access req.headers in beforeCreate

I need to get some of the headers 'user-agent' as well as the IP address how do you do that from within beforeCreate?

The req object is not available in waterline. So the next question is if your using blueprints.

If Yes, then you can doo like forrestranger suggests, but I think its better fit for a policy than over complicating it with middleware.

This is an example where I check for a companyId on every query.

// policy.js
module.exports = function(req, res, next) {
    req.options.where = _.assign({companyId : req.session.user.company.id}, req.options.where);
    req.query.companyId = req.session.user.companyId;
    return next();
};

If NO, then just attach the necessary info when you run your own create statement in the controller.

I would add a check in my beforeCreate that makes sure those fields are present as a form of self checking.

Assuming Sails 0.10, I don't think that's possible in beforeCreate just from digging through the waterline source code.

An alternative to that might be to have some middleware that attaches whatever info you need to the body so that it's available in beforeCreate and then removing it before you call next() so it doesn't cause your model validation to fail.