文件夹结构用于服务器端和胖客户端Web应用程序 [英] Folder structure for both server side and thick client web app
问题描述
目前我使用的Node.js的后端,要么ExtJS的或骨干客户端,我现在上的文件夹结构上完全糊涂了。
Currently I am using Node.js for the backend and either extjs or backbone for the client and I am now completely confused on the folder structure.
使用前preSS
我的文件夹结构如下
Using express
my folder structure is as follow
appname
|--controllers
|--models
| |--appmodel.js
|--public
| |--css
| |--js // any client-side javascripts
|--routes
| |--router.js
|--views
| |--appview.ejs
|--app.js
其中, app.js
是入口点,它使用 router.js
来处理路由和渲染观点。这工作正常,如果它仅仅是服务器端的开发。现在,如果我想使用ExtJS的或骨干客户端,我应该怎么安排我的code?我应该把它添加到公共
文件夹或的意见
?
where app.js
is the point of entry and it uses router.js
to handle routing and rendering of the views. This works fine if it is only server-side development. Now if I want to use ExtJS or Backbone for the client, how should I organize my code? Should I add it to public
folder or views
?
appname
|--controllers
| |--extbasedcontroller.js // correct location?
|--models
| |--appmodel.js
| |--extbasedmodels.js // correct location?
|--public
| |--css
| |--js
| | |--extjs // extjs files
|--routes
| |--router.js
|--views
| |--appview.ejs
| |--extbasedview.ejs // correct location?
|--app.js
如果是这样的话,我应该在哪里把我的ExtJS的文件模式?如果我把它放在模式
文件夹的感觉就像我一个文件夹中混淆了客户端和服务器code和它的将是混乱...
If this is the case, where should I put the model for my extjs files? If I put it in models
folder it feels like I'm mixing up client and server code in one folder and it's going to be confusing...
推荐答案
在你的地方,我会做这种方式:
In your place, I would do that way:
appname
|--ServerCode
| |--controllers
| |--models
| | |--appmodel.js
| |--routes
| | |--router.js
| |--views
| | |--appview.ejs
| |--app.js
|--public
| |--css
| |--js // any client-side javascripts
| |--models
| |--controllers
| |--...
主要思路是将公用文件夹的你的服务器范围的JavaScript 文件。
在这里看到一个例子: https://github.com/ madhums /节点前preSS-猫鼬-DEMO /
See an example here: https://github.com/madhums/node-express-mongoose-demo/
这篇关于文件夹结构用于服务器端和胖客户端Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!