koa 2.13.0 → 2.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/History.md CHANGED
@@ -1,4 +1,58 @@
1
1
 
2
+ 2.13.4 / 2021-10-19
3
+ ==================
4
+
5
+ **fixes**
6
+ * [[`dbc9c5a`](http://github.com/koajs/koa/commit/dbc9c5a47e2b2799cab403186fdb010df5df6f67)] - fix: Do not response Content-Length if Transfer-Encoding is defined (#1602) (Yiyu He <<dead_horse@qq.com>>)
7
+
8
+ 2.13.3 / 2021-09-24
9
+ ==================
10
+
11
+ **fixes**
12
+ * [[`a37a2e5`](http://github.com/koajs/koa/commit/a37a2e5eec8997661a35ca10210f1d9950976041)] - fix: compatible with node-v12.19.0 & earlier (#1590) (hyj1991 <<yeekwanvong@gmail.com>>)
13
+
14
+ 2.13.2 / 2021-09-24
15
+ ==================
16
+
17
+ **fixes**
18
+ * [[`04acf02`](http://github.com/koajs/koa/commit/04acf0281a5dcb3fd463d4c8537984c686d0b96f)] - fix: nodejs deprecated api <DEP0148> (#1585) (#1588) (hyj1991 <<yeekwanvong@gmail.com>>)
19
+
20
+ **others**
21
+ * [[`3435e78`](http://github.com/koajs/koa/commit/3435e7864a59cca2835ebaad96c4eda801b99b24)] - lint++ (jongleberry <<jonathanrichardong@gmail.com>>)
22
+ * [[`2cd6618`](http://github.com/koajs/koa/commit/2cd66182f46965f1d824c24826e85df251cca3d2)] - Fix grammar mistake (#1527) (Matheus Souza <<37983247+souzasmatheus@users.noreply.github.com>>)
23
+ * [[`16ab46e`](http://github.com/koajs/koa/commit/16ab46e9f2b5411fd1c50312ac03719f0a90df61)] - chore: upgrade koa-convert dependency to ^2.0.0 (#1535) (Christian Rodemeyer <<atombrenner@users.noreply.github.com>>)
24
+ * [[`65113ca`](http://github.com/koajs/koa/commit/65113ca38af634e4b1002d5bc40917cc09a7b7c6)] - Fix jsdoc types for constructor (#1541) (Piotr Kuczynski <<piotr.kuczynski@gmail.com>>)
25
+ * [[`03e6317`](http://github.com/koajs/koa/commit/03e6317df24d2dce0c1f08869326149f766f1e41)] - :arrow_up: debug (jongleberry <<jonathanrichardong@gmail.com>>)
26
+ * [[`b37a2d0`](http://github.com/koajs/koa/commit/b37a2d09c137d9a553a0bdf8589b60c7f6425160)] - :arrow_up: eslint dependencies (jongleberry <<jonathanrichardong@gmail.com>>)
27
+ * [[`4a410cc`](http://github.com/koajs/koa/commit/4a410cc2fbd923868cac6a622f12cc652586abee)] - migrate assert.deepEqual => .deepStrictEqual (jongleberry <<jonathanrichardong@gmail.com>>)
28
+ * [[`4545b59`](http://github.com/koajs/koa/commit/4545b59aa521e377a4ebb0ccbb8abec01981fbf4)] - test: switch tests to jest (jongleberry <<jonathanrichardong@gmail.com>>)
29
+ * [[`596cfd5`](http://github.com/koajs/koa/commit/596cfd542ccd1d89d97453e29cf499d49a82e743)] - migrate assert.strict => .strictEqual (jongleberry <<jonathanrichardong@gmail.com>>)
30
+ * [[`be3e8b6`](http://github.com/koajs/koa/commit/be3e8b68ab58d469f0f450284528dbef32e2d7ba)] - test: switch to github actions (jongleberry <<jonathanrichardong@gmail.com>>)
31
+ * [[`a2570e3`](http://github.com/koajs/koa/commit/a2570e3ee622cfa5214c2f756ea03b3b7143dbf7)] - package: update bench scripts (jongleberry <<jonathanrichardong@gmail.com>>)
32
+ * [[`000acf0`](http://github.com/koajs/koa/commit/000acf06ab3e37006569addc8ace5c0a4365daa1)] - npm: enable package-lock (jongleberry <<jonathanrichardong@gmail.com>>)
33
+ * [[`47fdbca`](http://github.com/koajs/koa/commit/47fdbca8b1c3999c5726f54531f8b47640a65a6f)] - delete benchmarks (jongleberry <<jonathanrichardong@gmail.com>>)
34
+ * [[`0056f90`](http://github.com/koajs/koa/commit/0056f901e89fd0781067b2c9592fd5909f9ba94a)] - Create dependabot.yml (jongleberry <<jonathanrichardong@gmail.com>>)
35
+ * [[`698ce0a`](http://github.com/koajs/koa/commit/698ce0afbfac6480400625729a4b8fc4b4203fdc)] - test: fix typo in status.js (Ikko Ashimine <<eltociear@gmail.com>>)
36
+ * [[`eb51cf5`](http://github.com/koajs/koa/commit/eb51cf5fb35b39592a050b25fd261a574f547cfa)] - doc: app.keys needs to be long enought and random (#1520) (Yiyu He <<dead_horse@qq.com>>)
37
+
38
+ 2.13.1 / 2021-01-04
39
+ ==================
40
+
41
+ **fixes**
42
+ * [[`b5472f4`](http://github.com/koajs/koa/commit/b5472f4cbb87349becae36b4a9ad5f76a825abb8)] - fix: make ESM transpiled CommonJS play nice for TS folks, fix #1513 (#1518) (miwnwski <<m@iwnw.ski>>)
43
+ * [[`68d97d6`](http://github.com/koajs/koa/commit/68d97d69e4536065504bf9ef1e348a66b3f35709)] - fix: fixed order of vulnerability disclosure addresses (niftylettuce <<niftylettuce@gmail.com>>)
44
+
45
+ **others**
46
+ * [[`b4398f5`](http://github.com/koajs/koa/commit/b4398f5d68f9546167419f394a686afdcb5e10e2)] - correct verb tense in doc (#1512) (Matan Shavit <<71092861+matanshavit@users.noreply.github.com>>)
47
+ * [[`39e1a5a`](http://github.com/koajs/koa/commit/39e1a5a380aa2bbc4e2d164e8e4bf37cfd512516)] - fixed multiple grammatical errors in docs. (#1497) (Hridayesh Sharma <<vyasriday7@gmail.com>>)
48
+ * [[`aeb5d19`](http://github.com/koajs/koa/commit/aeb5d1984dcc5f8e3386f8f9724807ae6f3aa1c4)] - docs: added niftylettuce@gmail.com to vulnerability disclosure (niftylettuce <<niftylettuce@gmail.com>>)
49
+ * [[`6e1093b`](http://github.com/koajs/koa/commit/6e1093be27b41135c8e67fce108743d54e9cab67)] - docs: remove babel from readme (#1494) (miwnwski <<m@iwnw.ski>>)
50
+ * [[`38cb591`](http://github.com/koajs/koa/commit/38cb591254ff5f65a04e8fb57be293afe697c46e)] - docs: update specific for auto response status (AlbertAZ1992 <<ziyuximing@163.com>>)
51
+ * [[`2224cd9`](http://github.com/koajs/koa/commit/2224cd9b6a648e7ac2eb27eac332e7d6de7db26c)] - docs: remove babel ref. (#1488) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
52
+ * [[`d51f983`](http://github.com/koajs/koa/commit/d51f98328c3b84493cc6bda0732aabb69e20e3a1)] - docs: fix assert example for response (#1489) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
53
+ * [[`f8b49b8`](http://github.com/koajs/koa/commit/f8b49b859363ad6c3d9ea5c11ee62341407ceafd)] - chore: fix grammatical and spelling errors in comments and tests (#1490) (Matt Kubej <<mkubej@gmail.com>>)
54
+ * [[`d1c9263`](http://github.com/koajs/koa/commit/d1c92638c95d799df2fdff5576b96fc43a62813f)] - deps: update depd >> v2.0.0 (#1482) (imed jaberi <<imed_jebari@hotmail.fr>>)
55
+
2
56
  2.13.0 / 2020-06-21
3
57
  ==================
4
58
 
package/Readme.md CHANGED
@@ -160,40 +160,6 @@ Learn more about the application object in the [Application API Reference](docs/
160
160
  - [FAQ](docs/faq.md)
161
161
  - [API documentation](docs/api/index.md)
162
162
 
163
- ## Babel setup
164
-
165
- If you're not using `node v7.6+`, we recommend setting up `babel` with [`@babel/preset-env`](https://babeljs.io/docs/en/next/babel-preset-env):
166
-
167
- ```bash
168
- $ npm install @babel/register @babel/preset-env @babel/cli --save-dev
169
- ```
170
-
171
- In development, you'll want to use [`@babel/register`](https://babeljs.io/docs/en/next/babel-register):
172
-
173
- ```bash
174
- node --require @babel/register <your-entry-file>
175
- ```
176
-
177
- In production, you'll want to build your files with [`@babel/cli`](https://babeljs.io/docs/en/babel-cli). Suppose you are compiling a folder `src` and you wanted the output to go to a new folder `dist` with non-javascript files copied:
178
-
179
- ```bash
180
- babel src --out-dir dist --copy-files
181
- ```
182
-
183
- And have your `.babelrc` setup:
184
-
185
- ```json
186
- {
187
- "presets": [
188
- ["@babel/preset-env", {
189
- "targets": {
190
- "node": true
191
- }
192
- }]
193
- ]
194
- }
195
- ```
196
-
197
163
  ## Troubleshooting
198
164
 
199
165
  Check the [Troubleshooting Guide](docs/troubleshooting.md) or [Debugging Koa](docs/guide.md#debugging-koa) in
@@ -207,9 +173,7 @@ $ npm test
207
173
 
208
174
  ## Reporting vulnerabilities
209
175
 
210
- To report a security vulnerability, please do not open an issue, as this notifies attackers
211
- of the vulnerability. Instead, please email [dead_horse](mailto:heyiyu.deadhorse@gmail.com) and [jonathanong](mailto:me@jongleberry.com) to
212
- disclose.
176
+ To report a security vulnerability, please do not open an issue, as this notifies attackers of the vulnerability. Instead, please email [dead_horse](mailto:heyiyu.deadhorse@gmail.com), [jonathanong](mailto:me@jongleberry.com), and [niftylettuce](mailto:niftylettuce@gmail.com) to disclose.
213
177
 
214
178
  ## Authors
215
179
 
@@ -41,8 +41,8 @@ module.exports = class Application extends Emitter {
41
41
  * @param {string[]} [options.keys] Signed cookie keys
42
42
  * @param {boolean} [options.proxy] Trust proxy headers
43
43
  * @param {number} [options.subdomainOffset] Subdomain offset
44
- * @param {boolean} [options.proxyIpHeader] proxy ip header, default to X-Forwarded-For
45
- * @param {boolean} [options.maxIpsCount] max ips read from proxy ip header, default to 0 (means infinity)
44
+ * @param {string} [options.proxyIpHeader] Proxy IP header, defaults to X-Forwarded-For
45
+ * @param {number} [options.maxIpsCount] Max IPs read from proxy IP header, default to 0 (means infinity)
46
46
  *
47
47
  */
48
48
 
@@ -211,6 +211,15 @@ module.exports = class Application extends Emitter {
211
211
  const msg = err.stack || err.toString();
212
212
  console.error(`\n${msg.replace(/^/gm, ' ')}\n`);
213
213
  }
214
+
215
+ /**
216
+ * Help TS users comply to CommonJS, ESM, bundler mismatch.
217
+ * @see https://github.com/koajs/koa/issues/1513
218
+ */
219
+
220
+ static get default() {
221
+ return Application;
222
+ }
214
223
  };
215
224
 
216
225
  /**
@@ -278,4 +287,5 @@ function respond(ctx) {
278
287
  * Make HttpError available to consumers of the library so that consumers don't
279
288
  * have a direct dependency upon `http-errors`
280
289
  */
290
+
281
291
  module.exports.HttpError = HttpError;
package/lib/request.js CHANGED
@@ -146,7 +146,7 @@ module.exports = {
146
146
  },
147
147
 
148
148
  /**
149
- * Set pathname, retaining the query-string when present.
149
+ * Set pathname, retaining the query string when present.
150
150
  *
151
151
  * @param {String} path
152
152
  * @api public
@@ -163,7 +163,7 @@ module.exports = {
163
163
  },
164
164
 
165
165
  /**
166
- * Get parsed query-string.
166
+ * Get parsed query string.
167
167
  *
168
168
  * @return {Object}
169
169
  * @api public
@@ -176,7 +176,7 @@ module.exports = {
176
176
  },
177
177
 
178
178
  /**
179
- * Set query-string as an object.
179
+ * Set query string as an object.
180
180
  *
181
181
  * @param {Object} obj
182
182
  * @api public
@@ -199,7 +199,7 @@ module.exports = {
199
199
  },
200
200
 
201
201
  /**
202
- * Set querystring.
202
+ * Set query string.
203
203
  *
204
204
  * @param {String} str
205
205
  * @api public
@@ -216,7 +216,7 @@ module.exports = {
216
216
  },
217
217
 
218
218
  /**
219
- * Get the search string. Same as the querystring
219
+ * Get the search string. Same as the query string
220
220
  * except it includes the leading ?.
221
221
  *
222
222
  * @return {String}
@@ -406,7 +406,7 @@ module.exports = {
406
406
  },
407
407
 
408
408
  /**
409
- * Short-hand for:
409
+ * Shorthand for:
410
410
  *
411
411
  * this.protocol == 'https'
412
412
  *
@@ -422,7 +422,7 @@ module.exports = {
422
422
  * When `app.proxy` is `true`, parse
423
423
  * the "X-Forwarded-For" ip address list.
424
424
  *
425
- * For example if the value were "client, proxy1, proxy2"
425
+ * For example if the value was "client, proxy1, proxy2"
426
426
  * you would receive the array `["client", "proxy1", "proxy2"]`
427
427
  * where "proxy2" is the furthest down-stream.
428
428
  *
@@ -495,6 +495,7 @@ module.exports = {
495
495
  * @return {Object}
496
496
  * @api private
497
497
  */
498
+
498
499
  get accept() {
499
500
  return this._accept || (this._accept = accepts(this.req));
500
501
  },
@@ -505,6 +506,7 @@ module.exports = {
505
506
  * @param {Object}
506
507
  * @api private
507
508
  */
509
+
508
510
  set accept(obj) {
509
511
  this._accept = obj;
510
512
  },
@@ -607,7 +609,7 @@ module.exports = {
607
609
 
608
610
  /**
609
611
  * Check if the incoming request contains the "Content-Type"
610
- * header field, and it contains any of the give mime `type`s.
612
+ * header field and if it contains any of the given mime `type`s.
611
613
  * If there is no request body, `null` is returned.
612
614
  * If there is no content type, `false` is returned.
613
615
  * Otherwise, it returns the first `type` that matches.
package/lib/response.js CHANGED
@@ -191,7 +191,9 @@ module.exports = {
191
191
  */
192
192
 
193
193
  set length(n) {
194
- this.set('Content-Length', n);
194
+ if (!this.has('Transfer-Encoding')) {
195
+ this.set('Content-Length', n);
196
+ }
195
197
  },
196
198
 
197
199
  /**
@@ -433,6 +435,7 @@ module.exports = {
433
435
  * @return {boolean}
434
436
  * @api public
435
437
  */
438
+
436
439
  has(field) {
437
440
  return typeof this.res.hasHeader === 'function'
438
441
  ? this.res.hasHeader(field)
@@ -441,7 +444,7 @@ module.exports = {
441
444
  },
442
445
 
443
446
  /**
444
- * Set header `field` to `val`, or pass
447
+ * Set header `field` to `val` or pass
445
448
  * an object of header fields.
446
449
  *
447
450
  * Examples:
@@ -564,8 +567,9 @@ module.exports = {
564
567
  },
565
568
 
566
569
  /**
567
- * Flush any set headers, and begin the body
570
+ * Flush any set headers and begin the body
568
571
  */
572
+
569
573
  flushHeaders() {
570
574
  this.res.flushHeaders();
571
575
  }
@@ -577,6 +581,7 @@ module.exports = {
577
581
  * @return {Object}
578
582
  * @api public
579
583
  */
584
+
580
585
  /* istanbul ignore else */
581
586
  if (util.inspect.custom) {
582
587
  module.exports[util.inspect.custom] = module.exports.inspect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa",
3
- "version": "2.13.0",
3
+ "version": "2.13.4",
4
4
  "description": "Koa web app framework",
5
5
  "main": "lib/application.js",
6
6
  "exports": {
@@ -8,13 +8,22 @@
8
8
  "require": "./lib/application.js",
9
9
  "import": "./dist/koa.mjs"
10
10
  },
11
- "./": "./"
11
+ "./lib/request": "./lib/request.js",
12
+ "./lib/request.js": "./lib/request.js",
13
+ "./lib/response": "./lib/response.js",
14
+ "./lib/response.js": "./lib/response.js",
15
+ "./lib/application": "./lib/application.js",
16
+ "./lib/application.js": "./lib/application.js",
17
+ "./lib/context": "./lib/context.js",
18
+ "./lib/context.js": "./lib/context.js",
19
+ "./*": "./*.js",
20
+ "./*.js": "./*.js",
21
+ "./package": "./package.json",
22
+ "./package.json": "./package.json"
12
23
  },
13
24
  "scripts": {
14
- "test": "egg-bin test test",
15
- "test-cov": "egg-bin cov test",
16
- "lint": "eslint benchmarks lib test",
17
- "bench": "make -C benchmarks",
25
+ "test": "jest --forceExit",
26
+ "lint": "eslint --ignore-path .gitignore .",
18
27
  "authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS",
19
28
  "build": "gen-esm-wrapper . ./dist/koa.mjs",
20
29
  "prepare": "npm run build"
@@ -36,9 +45,9 @@
36
45
  "content-disposition": "~0.5.2",
37
46
  "content-type": "^1.0.4",
38
47
  "cookies": "~0.8.0",
39
- "debug": "~3.1.0",
48
+ "debug": "^4.3.2",
40
49
  "delegates": "^1.0.0",
41
- "depd": "^1.1.2",
50
+ "depd": "^2.0.0",
42
51
  "destroy": "^1.0.4",
43
52
  "encodeurl": "^1.0.2",
44
53
  "escape-html": "^1.0.3",
@@ -47,7 +56,7 @@
47
56
  "http-errors": "^1.6.3",
48
57
  "is-generator-function": "^1.0.7",
49
58
  "koa-compose": "^4.1.0",
50
- "koa-convert": "^1.2.0",
59
+ "koa-convert": "^2.0.0",
51
60
  "on-finished": "^2.3.0",
52
61
  "only": "~0.0.2",
53
62
  "parseurl": "^1.3.2",
@@ -56,16 +65,15 @@
56
65
  "vary": "^1.1.2"
57
66
  },
58
67
  "devDependencies": {
59
- "egg-bin": "^4.13.0",
60
- "eslint": "^6.5.1",
68
+ "eslint": "^7.32.0",
61
69
  "eslint-config-koa": "^2.0.0",
62
- "eslint-config-standard": "^14.1.0",
70
+ "eslint-config-standard": "^16.0.3",
63
71
  "eslint-plugin-import": "^2.18.2",
64
- "eslint-plugin-node": "^10.0.0",
65
- "eslint-plugin-promise": "^4.2.1",
66
- "eslint-plugin-standard": "^4.0.1",
72
+ "eslint-plugin-node": "^11.1.0",
73
+ "eslint-plugin-promise": "^5.1.0",
74
+ "eslint-plugin-standard": "^5.0.0",
67
75
  "gen-esm-wrapper": "^1.0.6",
68
- "mm": "^2.5.0",
76
+ "jest": "^27.0.6",
69
77
  "supertest": "^3.1.0"
70
78
  },
71
79
  "engines": {
@@ -74,5 +82,8 @@
74
82
  "files": [
75
83
  "dist",
76
84
  "lib"
77
- ]
85
+ ],
86
+ "jest": {
87
+ "testEnvironment": "node"
88
+ }
78
89
  }