【问题标题】:Why does MEAN stack suggest an MVC directory structure for the backend Express code?为什么 MEAN 堆栈建议后端 Express 代码使用 MVC 目录结构?
【发布时间】:2014-08-07 06:18:30
【问题描述】:

我一直在试验 MEAN 堆栈并玩弄应用程序结构。根据Mean.ioMean.js,服务器后端代码(用 Express 编写)的建议文件夹结构在我看来类似于 MVC:

-server
--- config                      # Configuration Files (see below)
--- controllers                 # Server side logic goes here
--- models                      # schema models goes here
--- routes                      # rest api endpoints routing - here
--- views                       # swig based html rendering - here

我的问题是: 是否有任何理由不为后端服务器代码采用基于模块的文件夹结构?在前端,他们为 AngularJS 代码推荐基于模块的文件夹结构。

特别是,我认为this stackoverflow response 在服务器代码的基于模块的文件夹结构方面令人信服。

总体而言,MEAN 堆栈看起来非常酷,我想更好地了解如何最好地利用它。

【问题讨论】:

    标签: node.js angularjs express mongoose mean-stack


    【解决方案1】:

    mean.io 的 0.4.0 版本将于下周发布,其文件夹结构已适应服务器和客户端的模块化方法。

    代码将被分解为“包”,每个包在内部都以 mvc 样式构造。

    我建议查看 mean.io 包以了解新结构的工作原理。 link to the documentation pages

    【讨论】:

    猜你喜欢
    • 2021-05-02
    • 2015-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2018-01-29
    • 2013-10-11
    • 1970-01-01
    相关资源
    最近更新 更多