跳到主要内容
CNode

谁有没有github上express4.X的开源项目,刚开始学习express,想学习一下代码设计

Kkoroshi发布于 12 年前最后回复 12 年前
884330

比如:controller router什么的怎么放。 刚看了一眼那个nodeclube 是通过 app.js 里 route(app)传过去的 我看到过两个方法一个是这样的一个是定义一个全局的 app变量

不知道4.X新增了router之后是否有更好的写法

查看回复

回复 (8)

D
dlutwuwei#112 年前

刚出来没有什么项目,其实也没有太大的区别,就是把connect隐藏的东西都暴露出来

S
SnipeV5#212 年前

直接用express4 创建项目,路由直接会提供出来

H
Hanggi#312 年前

router .get('/',fn); .post('/login',fn)

C
czing#412 年前

啃express源码, 成本高, 回报大...

D
dongfeng4433#512 年前

同求啊

Y
yangheng#612 年前
引用 Hanggirouter .get('/',fn); .post('/login',fn)

@Hanggi 这种写法是不正确的,express.router(path).all(fn).get(fn).post(fn) 才是正确的。path 是在route 里面穿进去的 源代码如下 methods.concat('all').forEach(function(method){ proto[method] = function(path){ var route = this.route(path) route[method].apply(route, slice.call(arguments, 1)); return this; }; });

T
tonyzhan#712 年前

请看我发布的文章:使用express4.x版和Jade模板重写《nodejs开发指南》微博实例 代码直接贴在文章里。

M
MiguelValentine#812 年前

https://github.com/MiguelValentine/metro

我的一个项目 conf/conf.js配置文件被拿掉了。 另外基于数据库驱动,如果你想稍微研究下也是可以的。

参与回复

登录后即可参与回复。登录