如何在NodeJS中构build模型和视图?

我正在编写一个基于NodeJS的服务器端和客户端JavaScript应用程序。 我有控制器,模型,视图和演示者。 我面临的问题是,代码的某些部分只需要服务器端,一些客户端和一些两者。

例如,控制器是纯服务器端的东西,所以他们不应该在客户端。 另一方面,演示者纯粹是客户端的东西,所以应该在客户端提供。

看看我目前糟糕的结构:

project\ project\public\index.js project\public\images\ project\protected\controllers\ project\protected\models\ project\protected\views\ project\protected\presenters\ 

我面对的问题是,公用文件夹是文档根,并且保护在文档根之外。 我需要能够在客户端和服务器端使用视图。 所以,我的意见不能被保护。 这同样适用于模型和其他东西吨。 我也需要能够访问他们的客户端。

我开始认为除了一些configuration文件之外,我必须将整个结构放在文档根目录下。 这是我应该做的吗? 这种方法有什么问题吗? 我在问,因为大多数Web框架(Django,Zend Framework)以框架在文档根之外的方式工作。

我的github结构 (过时)

 -- Main level project\ -- Your main app. Keep light project\app.js -- All your configuration, development/production setups project\app-configure -- Your server-side controllers/routing. Keep light project\controllers\ -- Any WebSocket specific code. project\socket-io\ -- Server side test project\test\ -- Your public folder. Client side can access these files. -- Serve this folder as static content project\public\ -- I keep my backbone collections here. Used on both server & client project\public\collections -- public css files project\public\css -- public js files. Including a main.js to bootstrap the router project\public\js -- public models used on both server & client. project\public\models -- client side router, used to router hashbang urls. Can use same routing -- logic as the server. This is virtually a second set of controllers around -- All your models project\public\routers\ -- public tests. QUnit based project\public\test\ -- View files project\public\views -- Templates used to render HTML. Used on client & server project\public\views\templates -- Backbone view files. Used to code up interaction, and business logic -- This uses templates to render HTML and DOM events to handle interaction project\public\views\backbone-views 

这是基于快递和骨干 。 控制器是express控制器 public \路由器是使用davis的客户端路由

基本上,因为MVC在客户端和服务器端重复使用,唯一不公开的是服务器端testing和服务器端控制器。 以及configuration设置和任何基于socket-io的代码。

我的build议很简单,只要在\public\

因为MVC在客户端和服务器上重复使用是一件新事物,所以没有任何可以看的例子。 除了在github上寻找大型开源的node.js网站外,