Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling default sails.js routes

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

like image 990
t3rminus Avatar asked Mar 18 '23 21:03

t3rminus


1 Answers

The 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.

like image 79
Konstantin Zolotarev Avatar answered Mar 29 '23 16:03

Konstantin Zolotarev