express中间件是个普通的函数,执行中间件是个阻塞的过程

  • expres执行 next() 是个阻塞的过程
  • express的异步,会破坏洋葱模型,express对洋葱模型兼容的不好

koa洋葱模型

  • await之前是穿入
  • await之后是穿出

express

  • request
  • response

request

  1. query
  2. param()
  3. route
  4. cookies
  5. signedCookies
  6. get()
  7. accepts()
  8. acceptsCharset()
  9. acceptsLanguage()
  10. is()
  11. ip
  12. ips
  13. path
  14. host
  15. fresh
  16. state
  17. xhr
  18. secure
  19. subdomains
  20. originUrl

response

  1. status()
  2. set()
  3. get()
  4. redirect()
  5. cookie()
  6. clearCookie()
  7. location()
  8. send()
  9. json()
  10. jsonp()
  11. type()
  12. format()
  13. attchment()
  14. sendfile()
  15. download()
  16. links()
  17. locals
  18. render()