在 Sails.js/api/controllers 中创建子文件夹 [英] Create subfolders in Sails.js /api/controllers

查看:60
本文介绍了在 Sails.js/api/controllers 中创建子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:我想在/api/controllers 中创建一些子文件夹以组织我的源代码.我的问题是,一旦我创建了一个新文件夹,蓝图 api/routes/actions 似乎就不再起作用了.

here is my problem: I would like to create some subfolders inside /api/controllers in order to organize my source code. My problem there is that as soon as I create a new folder, blueprint api / routes / actions don't seem to work anymore.

从我所有的测试来看,如果我将/api/controller/UserController.js 更改为/api/controller/newpath/UserController.js,我将无法再享受蓝图的美妙之处.

From all my tests if I change /api/controller/UserController.js to /api/controller/newpath/UserController.js I can't get the beauty of blueprint working anymore.

有没有办法做到这一点?

Is there any way to do that?

谢谢伊曼纽尔

推荐答案

您可以进行设置.它有点未记录,但您可以在控制器上设置一个_config"对象

You can set this up. Its a bit undocumented, but you can setup a "_config" object on your controller

api/controllers/subFolder/YourController.js
...
module.exports = {
  _config: {
    model: 'YourModel' // case sensitive
    actions: true,
    shortcuts: true,
    rest: true
  }
}

看看这个答案https://stackoverflow.com/a/22062367/1821723

这篇关于在 Sails.js/api/controllers 中创建子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆