Devendra Verma Devendra Verma - 2 months ago 12
Node.js Question

Disable blueprint routes sails js

Hello I have model users, in which there is a foreign key of Orders model.
Now sails will automatically generate route

/users/:id/orders
. I have to disable this route. How to do this ? I have already tried to disable all routes of orders using:
_config : { actions: false, rest: false, shortcuts: false }
but it still doen't work

Answer

You can achieve this by adding custom routes, which will overwrite the blueprint action.

Use http://sailsjs.org/documentation/concepts/routes/custom-routes#?response-target-syntax

'/users/:id/orders': {response: 'forbidden'}

or http://sailsjs.org/documentation/concepts/routes/custom-routes#?function-target-syntax

'/users/:id/orders': function(req, res) {res.forbidden();}