Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: koajs/koa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 46f0c9102f2730ec89bd0ea0575ecdd87c514578
Choose a base ref
...
head repository: koajs/koa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3595ef58b96f1e5f2ff83384bfa0409a30797e7a
Choose a head ref
Loading
Showing with 3,714 additions and 3,097 deletions.
  1. +16 −0 .editorconfig
  2. +22 −0 .eslintrc.yml
  3. +12 −7 .travis.yml
  4. +20 −11 AUTHORS
  5. +74 −0 CODE_OF_CONDUCT.md
  6. +54 −0 History.md
  7. +1 −1 LICENSE
  8. +10 −19 Makefile
  9. +120 −39 Readme.md
  10. +2 −13 benchmarks/Makefile
  11. +0 −28 benchmarks/experimental/async.js
  12. +0 −9 benchmarks/experimental/index.js
  13. +7 −13 benchmarks/middleware.js
  14. +1 −1 benchmarks/run
  15. +16 −16 docs/api/context.md
  16. +67 −46 docs/api/index.md
  17. +45 −45 docs/api/request.md
  18. +46 −25 docs/api/response.md
  19. +60 −0 docs/error-handling.md
  20. +4 −10 docs/faq.md
  21. +70 −85 docs/guide.md
  22. +1 −1 docs/koa-vs-express.md
  23. +175 −163 lib/application.js
  24. +17 −15 lib/context.js
  25. +50 −47 lib/request.js
  26. +68 −53 lib/response.js
  27. +20 −11 package.json
  28. +5 −0 test/.eslintrc
  29. +0 −1,087 test/application.js
  30. +34 −0 test/application/context.js
  31. +56 −0 test/application/index.js
  32. +14 −0 test/application/inspect.js
  33. +69 −0 test/application/onerror.js
  34. +34 −0 test/application/request.js
  35. +819 −0 test/application/respond.js
  36. +34 −0 test/application/response.js
  37. +17 −0 test/application/toJSON.js
  38. +129 −0 test/application/use.js
  39. +3 −0 test/babel/.babelrc
  40. +42 −0 test/babel/_test.js
  41. +6 −0 test/babel/index.js
  42. +0 −23 test/context.js
  43. +7 −7 test/context/assert.js
  44. +76 −49 test/context/cookies.js
  45. +7 −7 test/context/inspect.js
  46. +109 −75 test/context/onerror.js
  47. +14 −14 test/context/state.js
  48. +72 −72 test/context/throw.js
  49. +9 −9 test/context/toJSON.js
  50. +0 −25 test/experimental/async.js
  51. +0 −7 test/experimental/index.js
  52. +21 −0 test/helpers/context.js
  53. +52 −52 test/request/accepts.js
  54. +34 −34 test/request/acceptsCharsets.js
  55. +25 −25 test/request/acceptsEncodings.js
  56. +34 −34 test/request/acceptsLanguages.js
  57. +19 −19 test/request/charset.js
  58. +24 −24 test/request/fresh.js
  59. +6 −6 test/request/get.js
  60. +6 −6 test/request/header.js
  61. +6 −6 test/request/headers.js
  62. +26 −26 test/request/host.js
  63. +28 −28 test/request/hostname.js
  64. +29 −29 test/request/href.js
  65. +14 −14 test/request/idempotent.js
  66. +12 −12 test/request/inspect.js
  67. +18 −18 test/request/ip.js
  68. +15 −15 test/request/ips.js
  69. +37 −38 test/request/is.js
  70. +10 −10 test/request/length.js
  71. +9 −11 test/request/origin.js
  72. +22 −14 test/request/path.js
  73. +30 −30 test/request/protocol.js
  74. +22 −22 test/request/query.js
  75. +30 −22 test/request/querystring.js
  76. +17 −17 test/request/search.js
  77. +6 −6 test/request/secure.js
  78. +6 −6 test/request/stale.js
  79. +9 −9 test/request/subdomains.js
  80. +10 −10 test/request/type.js
  81. +15 −15 test/response/append.js
  82. +34 −34 test/response/attachment.js
  83. +75 −75 test/response/body.js
  84. +17 −17 test/response/etag.js
  85. +98 −0 test/response/flushHeaders.js
  86. +11 −11 test/response/header.js
  87. +11 −11 test/response/headers.js
  88. +12 −12 test/response/inspect.js
  89. +32 −33 test/response/is.js
  90. +21 −22 test/response/last-modified.js
  91. +30 −30 test/response/length.js
  92. +16 −17 test/response/message.js
  93. +61 −61 test/response/redirect.js
  94. +6 −6 test/response/remove.js
  95. +17 −17 test/response/set.js
  96. +7 −7 test/response/socket.js
  97. +67 −79 test/response/status.js
  98. +44 −45 test/response/type.js
  99. +18 −18 test/response/vary.js
  100. +11 −11 test/response/writeable.js
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
22 changes: 22 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Support ES2016 features
parser: babel-eslint

extends: standard

plugins: [
"babel"
]

rules:
arrow-parens: 0
babel/arrow-parens: [2, "as-needed"]

eqeqeq: 0
no-return-assign: 0 # fails for arrow functions
no-var: 2
semi: [2, always]
space-before-function-paren: [2, never]
yoda: 0
arrow-spacing: 2
dot-location: [2, "property"]
prefer-arrow-callback: 2
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: node_js
node_js:
- "0.12"
- "1"
- "2"
- "3"
- "4"
sudo: false
script: "make test-travis"
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
- "5"
before_script:
- sudo apt-get install build-essential libssl-dev git
- git clone https://github.com/wg/wrk.git
- cd wrk && make && sudo cp wrk /usr/local/bin && cd ..
script:
- make lint
- make test-travis
- make bench
after_script:
- npm install codecov
- ./node_modules/.bin/codecov
31 changes: 20 additions & 11 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
TJ Holowaychuk <tj@vision-media.ca>
Jonathan Ong <jonathanrichardong@gmail.com>
dead_horse <dead_horse@qq.com>
Tejas Manohar <me@tejas.io>
Yiyu He <dead_horse@qq.com>
fengmk2 <fengmk2@gmail.com>
Julian Gruber <julian@juliangruber.com>
Rui Marinho <rpm@seegno.com>
Jonathan Ong <me@jongleberry.com>
fengmk2 <m@fengmk2.com>
Rui Marinho <rpm@seegno.com>
jongleberry <jonathanong@users.noreply.github.com>
Ian Storm Taylor <ian@ianstormtaylor.com>
pana <pana.wang@outlook.com>
alsotang <alsotang@gmail.com>
Ian Storm Taylor <ian@ianstormtaylor.com>
PatrickJS <github@gdi2290.com>
yoshuawuyts <i@yoshuawuyts.com>
Jesús Rodríguez Rodríguez <Foxandxss@gmail.com>
Sonny Piers <sonny@fastmail.net>
Jesus Rodriguez <foxandxss@gmail.com>
Jingwei "John" Liu <liujingwei@gmail.com>
alsotang <alsotang@gmail.com>
Jesús Rodríguez Rodríguez <Foxandxss@gmail.com>
Bryan Bess <squarejaw@bsbess.com>
Robert Sköld <robert@publicclass.se>
yoshuawuyts <i@yoshuawuyts.com>
Johan Bergström <bugs@bergstroem.nu>
Karl Böhlmark <karl.bohlmark@gmail.com>
Kenneth Ormandy <kenneth@chloi.io>
@@ -28,33 +30,38 @@ Matthew King <mking@users.noreply.github.com>
Matthew Mueller <mattmuelle@gmail.com>
Michaël Zasso <mic.besace@gmail.com>
Nathan Rajlich <nathan@tootallnate.net>
Aaron Heckmann <aaron.heckmann+github@gmail.com>
New Now Nohow <empty@cqdr.es>
Peeyush Kushwaha <peeyush.p97@gmail.com>
Phillip Alexander <git@phillipalexander.io>
Qiming zhao <chemzqm@gmail.com>
Robert Sköld <robert@publicclass.se>
Ryunosuke SATO <tricknotes.rs@gmail.com>
Sterling Williams <sterlingw@qualtrics.com>
Teoman Soygul <teo@soygul.com>
Tiago Ribeiro <tlr@seegno.com>
Tim Schaub <tim.schaub@gmail.com>
Travis Jeffery <tj@travisjeffery.com>
Veselin Todorov <veselin@veselin.bg>
Yazhong Liu <l900422@vip.qq.com>
Yazhong Liu <yorkiefixer@gmail.com>
Yoshua Wuyts <yoshuawuyts@gmail.com>
bhanuc <bhanuc@iitk.ac.in>
fengmk2 <m@fengmk2.com>
fundon <cfddream@gmail.com>
gyson <eilian.yunsong@gmail.com>
haoxin <coderhaoxin@outlook.com>
jeromew <jerome.wagner@m4x.org>
llambda <xxgsoftware@gmail.com>
mako-taco <jake.y.scott@gmail.com>
mdemo <mds@xue.bi>
nicoder <nicolas.dermine@gmail.com>
superchink <superchink@gmail.com>
tmilewski <tmilewski@gmail.com>
yosssi <yoshida.keiji.84@gmail.com>
Aaron Heckmann <aaron.heckmann+github@gmail.com>
zensh <admin@zensh.com>
New Now Nohow <empty@cqdr.es>
Adam L <skyros@gmail.com>
AlexeyKhristov <AlexeyKhristov@users.noreply.github.com>
Ben Reinhart <breinhart@groupon.com>
C.T. Lin <chentsulin@gmail.com>
Chris Tarquini <chris@ilsken.com>
Christoffer Hallas <hallas@users.noreply.github.com>
Darren Cauthon <darren@cauthon.com>
@@ -68,3 +75,5 @@ Hugh Kennedy <hughskennedy@gmail.com>
Jan Buschtöns <buschtoens@gmail.com>
Jan Carlo Viray <virayjancarlo@yahoo.com>
Jed Schmidt <where@jed.is>
Jesus Rodriguez <foxandxss@gmail.com>
Jingwei "John" Liu <liujingwei@gmail.com>
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at tj@tjholowaychuk.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
54 changes: 54 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@

2.0.0 / 2016-03-23
==================

* merge v1.1.2 and v1.2.0 changes
* include `koa-convert` so that generator functions still work
* NOTE: generator functions are deprecated in v2 and will be removed in v3
* improve linting
* improve docs

1.2.0 / 2016-03-03
==================

* add support for `err.headers` in `ctx.onerror()`
- see: https://github.com/koajs/koa/pull/668
- note: you should set these headers in your custom error handlers as well
- docs: https://github.com/koajs/koa/blob/master/docs/error-handling.md
* fix `cookies`' detection of http/https
- see: https://github.com/koajs/koa/pull/614
* deprecate `app.experimental = true`. Koa v2 does not use this signature.
* add a code of conduct
* test against the latest version of node
* add a lot of docs

1.1.2 / 2015-11-05
==================

* ensure parseurl always working as expected
* fix Application.inspect() – missing .proxy value.

2.0.0-alpha.3 / 2015-11-05
==================

* ensure parseurl always working as expected. #586
* fix Application.inspect() – missing .proxy value. Closes #563

2.0.0-alpha.2 / 2015-10-27
==================

* remove `co` and generator support completely
* improved documentation
* more refactoring into ES6

2.0.0-alpha.1 / 2015-10-22
==================

* change the middleware signature to `async (ctx, next) => await next()`
* drop node < 4 support and rewrite the codebase in ES6

1.1.1 / 2015-10-22
==================

* do not send a content-type when the type is unknown #536

1.1.0 / 2015-10-11
==================

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2015 Koa contributors
Copyright (c) 2016 Koa contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
29 changes: 10 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
SRC = lib/*.js

include node_modules/make-lint/index.mk

BIN = iojs

ifeq ($(findstring io.js, $(shell which node)),)
BIN = node
endif

ifeq (node, $(BIN))
FLAGS = --harmony
endif

REQUIRED = --require should --require should-http

TESTS = test/application \
TESTS = test/application/* \
test/context/* \
test/request/* \
test/response/* \
test/experimental/index.js
test/babel/index.js

lint:
@./node_modules/.bin/eslint benchmarks lib test

test:
@NODE_ENV=test $(BIN) $(FLAGS) \
@NODE_ENV=test node \
./node_modules/.bin/_mocha \
$(REQUIRED) \
$(TESTS) \
--bail

test-cov:
@NODE_ENV=test $(BIN) $(FLAGS) \
@NODE_ENV=test node \
./node_modules/.bin/istanbul cover \
./node_modules/.bin/_mocha \
-- -u exports \
$(REQUIRED) \
$(TESTS) \
--bail

test-travis:
@NODE_ENV=test $(BIN) $(FLAGS) \
test-travis: lint
@NODE_ENV=test node \
./node_modules/.bin/istanbul cover \
./node_modules/.bin/_mocha \
--report lcovonly \
@@ -49,4 +40,4 @@ test-travis:
bench:
@$(MAKE) -C benchmarks

.PHONY: test bench
.PHONY: lint test bench
Loading