Reputation: 1269
Suppose I have 3 models A, B, C. Is there any way to enable rest API for model C only?
blueprints.js can only turn on/off the rest API function for all models.
I think if it can't be configured, a controller is needed.
Upvotes: 0
Views: 191
Reputation: 2260
You need a controller to override the configurations of your blueprints, since you only want one model to have rest API, then you can set it to false(globally) in your blueprint settings, and for that particular model(C), you create a controller and add a custom _config
property that will override what was set in the blueprints settings.
Like this
var ModelController = {
_config: {
actions: true,
shortcuts: true,
rest: true
}
}
module.exports = ModelController
According to the docs the opposite is true (dissabling), and its what i've tried in the past, but i believe it will work like this. If not, you'll have to enable the restApi for all of them and disable it for all but your model C controller.
This is the link to the docs related to that http://sailsjs.org/documentation/reference/blueprint-api
I'm not aware of any other option right now, but let me know if it works.
Upvotes: 1