我的 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和backbone的。控制器是express-controllers public\routers 是使用davis的客户端路由
基本上因为 MVC 在客户端和服务器之间被大量重用,唯一不公开的是服务器端测试和服务器端控制器。以及配置设置和任何基于 socket-io 的代码。
我的建议很简单,两者都使用的任何东西都可以\public\
因为在客户端和服务器上重用 MVC 是一个新事物,所以没有任何示例可以查看。除了在 github 上寻找大型开源 node.js 网站。