Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

express middleware #24

Open
magicdawn opened this issue Mar 31, 2015 · 3 comments
Open

express middleware #24

magicdawn opened this issue Mar 31, 2015 · 3 comments
Labels

Comments

@magicdawn
Copy link
Owner

express的各种中间件......

@magicdawn magicdawn added the node label Mar 31, 2015
@magicdawn
Copy link
Owner Author

body-parser

之前的做法

bodyParser('json') // 之类的 被deprecated

现在的是

bodyParser.json() // application/json
bodyParser.urlencoded({ extend: true }) // application/x-www-form-urlencoded
// 默认的 extend 默认值被deprecated, 提供extend 得到类似json的体验,否则, key-value对的value只能是string or array

@magicdawn
Copy link
Owner Author

express-state

expose(hello,world)

(function (root) {
// -- Data --
root.world = "hello";
}(this));

设置 state namespace 后

(function (root) {
// -- Data --
root.MT || (root.MT = {});
root.MT.world = "hello";
}(this));

@magicdawn
Copy link
Owner Author

magicdawn commented Jun 29, 2016

express req, res

  • 1在 middleware 中的 req, res
  • 2app.request / app.response
  • 3require('express/lib/request') / response

1.__proto__ = 2 https://github.com/expressjs/express/blob/master/lib/middleware/init.js#L28-L29
2.__proto = 3 https://github.com/expressjs/express/blob/master/lib/express.js#L44-L45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant