MEAN堆栈的文件夹结构 [英] folder structure for MEAN stack

查看:68
本文介绍了MEAN堆栈的文件夹结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注有关MEAN堆栈的教程,我想使用一个干净的文件夹结构.我读过很多文章,其中说应用程序的每个模块(我们称其为模块)都有一个文件夹,并将视图/模型/控制器/等分组在一起.

I'm following a tutorial on the MEAN stack and I'd like to have a clean folder structure to work with. I've read plenty of articles that say to have a folder for each (let's call it) module of the application with the views/models/controllers/etc.. grouped together.

我喜欢这种方法,并且已经开始这样做,但是我需要一些帮助.

I like this approach and I've already started doing this, however I'd like some assistance.

现在,我的目录结构看起来像这样:

right now, my directory structure looks something like this:

    • 观看次数
    • 模型
    • 路线
    • 公开
    • root
      • views
      • models
      • routes
      • public

      到目前为止,我已经有了一个带有角度控制器的主index视图,所以我要做的是在public下创建一个新文件夹并将其命名为index

      up till now, I have a main index view with its angular controller, so what I did is, make a new folder under public and named it index

      任何带有星号的东西都是一个文件夹(*)

      anything with an asterisk is a folder (*)

      • 根*
        • 公开*
          • 索引*
            • index.ejs
            • 角*
              • indexController.js
              • someService.js
              • root*
                • public*
                  • index*
                    • index.ejs
                    • angular*
                      • indexController.js
                      • someService.js
                      • someCss.Css
                      • 一些jQuery或js文件
                      • otherIndex.ejs
                      • 角*
                        • otherController.js
                        • someService.js
                        • otherIndex.ejs
                        • angular*
                          • otherController.js
                          • someService.js
                          • someCss.Css
                          • 一些jQuery或js文件

                          第一个问题是,到目前为止效果良好吗?所有这些都属于公用文件夹吗?

                          first question is, is this good so far? does all of this belong in the public folder?

                          我的第二点与后端有关.我开始构建一些模型,本教程说是将它们放在models文件夹中.但是,我宁愿将模型与它们各自的模块"保持在一起,所以我宁愿将索引模型放在索引视图所在的文件夹中.可能在名为models的索引下创建一个新文件夹,并将其添加到其中:

                          my second has to do with the back end. I'm starting to build some models and the tutorial is saying to put them in the models folder. However, I'd rather keep models with their respective "module", so the index model I'd rather put in the folder where the index view lives. probably create a new folder under index called models and add it in there:

                          • root *
                            • 公开*
                              • 索引*
                                • index.ejs
                                • 角*
                                  • indexController.js
                                  • someService.js
                                  • root*
                                    • public*
                                      • index*
                                        • index.ejs
                                        • angular*
                                          • indexController.js
                                          • someService.js
                                          • someCss.Css
                                          • 一些jQuery或js文件
                                          • someModel.js

                                          ,但这似乎不是放置模型文件的正确位置,因为这是公用文件夹,并且模型是后端代码.有什么更好的方法可以做我的事情吗?还是应该仅将模型放在主模型文件夹中?并只是将前端按模块"分组,而所有模型都一起放在模型"文件夹中?

                                          but this doesn't seem to be the right place to put a model file since this is the public folder, and a model is back-end code. Is there a better approach to what I'm doing? or should I have the models just be in the main models folder? and just have the front end be grouped by 'module' while the models all just sit together in the models folder?

                                          推荐答案

                                          新的MEAN js堆栈采用了不同的方法,它们不再具有单独的服务器端文件夹和客户端文件夹.现在,分离是在模块级别

                                          The new MEAN js stack follows a different approach and they no longer have separate server side folder and client side folder. Now the separation is at the module level

                                          您可以看到每个模块都有客户端,服务器和测试文件夹.有关更多信息,您可以查看其最新的存储库.

                                          You can see that each module has client, server and test folder. For more info you can check out their latest repository.

                                          这篇关于MEAN堆栈的文件夹结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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