This allows sails to handle requests and responses via the jsonapi.org specs. For example:
{
user: [{
id: 1,
name: 'Brian Jemilo II'
},
{
id: 2,
name: 'Mike R McNeil'
}]
}
In the policy jsonapi.js If you are in need to have the resource property to be plural,
Wrap req.body[req.options.model]
in a variable and append + 's'
resource = req.body[req.options.model] + 's';
Then replace req.body[req.options.model]
with resource
In the responses ok.js Format Responses to Jsonapi.org spec standards.
var format = {};
format[req.options.model] = data;
data = format;
In config policies.js
Add '*': 'jsonapi'
this way it will apply to every controller.
For frontend frameworks like Ember.js that are heavily and unforgivingly opinionated.