禁用蓝图路线航行js

你好,我有模型的用户,其中有订单模式的外键。 现在帆会自动生成route /users/:id/orders 。 我必须禁用这条路线。 这个怎么做 ? 我已经尝试使用以下命令禁用所有的命令路由: _config : { actions: false, rest: false, shortcuts: false }但是仍然不能工作

您可以通过添加自定义路线来实现此目的,这将覆盖蓝图操作。

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

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

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

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

您可以通过策略控制对此模型的访问。

要阻止所有将下面的代码放在/config/policies.js文件中:

命令 : {
   '*':假
 },

你也可以覆盖路由/config/routes.js

'/:collection/:id/:model': {response: 'forbidden'}

或者你可以按照你所做的方式,在这个模型上禁用其他路线

只要确保你把整个块,包括出口线:

 module.exports = { _config: { rest: false } };