2

我想知道在使用nvst构建 NodeJS 应用程序时,您通常如何组织应用程序结构。当我创建我的应用程序时,它会自动为我构建这个结构: 在此处输入图像描述

所以,我首先想到的是,我应该把控制器放在哪里以及如何将它们与路由和视图连接起来?

另外,如何组织我的单元测试逻辑?

4

1 回答 1

0

An NTVS angular app is still just an angular app. The advice in AngularJS application file structure applies.

Going further, General principle: You should be able to find what you're looking for without excessive drilling or scrolling.

Schemes:

  • for smaller apps, folder by type: controller; service; model
  • for larger apps, folder by function: user; cart; search; grid

I lean toward folder by function, as it keeps files that may need to be modified at the same time together.

As for unit tests, I have seen either myfile.test.js or myfile.spec.js sitting right beside myfile.js. If you do not include the test files in the index.js, then they won't be loaded and don't cause a problem.

于 2015-06-22T19:58:08.753 回答