I'm setting up a basic Sails.js app, and I'm trying to disable the default routing system in sails.js. The documentation here seems to indicate it can be disabled in the /config/blueprints.js
file, by setting module.exports.blueprints = { actions: false };
However, when I do sails lift
, I'm still able to access my default controller at /foo
Edit: This is using Sails v0.10.5, with no changes other than the two files below.
/** /api/controllers/FooController.js **/
module.exports = {
index: function(req, res) {
return res.send("blah blah blah");
}
};
/** /config/blueprints.js **/
module.exports.blueprints = {
actions: false,
rest: false,
shortcuts: false,
prefix: '',
pluralize: false,
populate: false,
autoWatch: true,
defaultLimit: 30
};
Additionally, the issue continues to occur if I disable blueprints on a per-controller basis:
/** /api/controllers/FooController.js **/
module.exports = {
_config: { actions: false, shortcuts: false, rest: false },
index: function(req, res) {
return res.send("blah blah blah");
}
};
The controller is still accessible at /foo
I'm setting up a basic Sails.js app, and I'm trying to disable the default routing system in sails.js. The documentation here seems to indicate it can be disabled in the /config/blueprints.js
file, by setting module.exports.blueprints = { actions: false };
However, when I do sails lift
, I'm still able to access my default controller at /foo
Edit: This is using Sails v0.10.5, with no changes other than the two files below.
/** /api/controllers/FooController.js **/
module.exports = {
index: function(req, res) {
return res.send("blah blah blah");
}
};
/** /config/blueprints.js **/
module.exports.blueprints = {
actions: false,
rest: false,
shortcuts: false,
prefix: '',
pluralize: false,
populate: false,
autoWatch: true,
defaultLimit: 30
};
Additionally, the issue continues to occur if I disable blueprints on a per-controller basis:
/** /api/controllers/FooController.js **/
module.exports = {
_config: { actions: false, shortcuts: false, rest: false },
index: function(req, res) {
return res.send("blah blah blah");
}
};
The controller is still accessible at /foo
3 Answers
Reset to default 7The problem is a little bit tricky. You are trying to open Controller.index method. At the same time you are disabled routing for all actions.
But actually Sails.js in 0.10.5 has additional configuration that disables index route from controller. Its name: index.
So you disabled auto routing for all actions except index..
To disable all auto routes you have to set:
_config: {
actions: false,
shortcuts: false,
rest: false,
index: false
}
Seems that somebody just forgot to add this into docs.
You can do this by using policies under the config folder.
module.exports.policies = {
YourControllerName: {
'find': true,
'*': false
}
}
To disable the default rest routes generated for models you should set rest: false
in file /config/blueprints.js
This solution is for sails V1.x
/***************************************************************************
* *
* Automatically expose RESTful routes for your models? *
* *
***************************************************************************/
rest: false,