我想知道在使用nvst构建 NodeJS 应用程序时,您通常如何组织应用程序结构。当我创建我的应用程序时,它会自动为我构建这个结构:
所以,我首先想到的是,我应该把控制器放在哪里以及如何将它们与路由和视图连接起来?
另外,如何组织我的单元测试逻辑?
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:
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.