concept Gravatar URL in category sails

appears as: Gravatar URL, Gravatar URL
Sails.js in Action

This is an excerpt from Manning's book Sails.js in Action.

A transformation changes the format of a model attribute to comply with some requirement. For example, when a user signs up, you’ll use the user’s email to create a Gravatar URL on the backend.

Now, you’ve validated your inputs, encrypted the password, and created a Gravatar URL. You’re ready to create a record for your user model.

The request passes the current user’s email address via the email parameter. You again use the .getImageUrl() machine to generate the Gravatar URL using the email parameter as the sole input. Because you’re using the synchronous version of the .getImageUrl() machine, you’ll wrap it in a try/catch to guard against Brushfire crashing if you get an error. Last, you’ll respond with res.json() returning the generated URL to the frontend.