koa 2.12.1 → 2.13.3

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,63 @@
1
1
 
2
+ 2.13.3 / 2021-09-24
3
+ ==================
4
+
5
+ **fixes**
6
+ * [[`a37a2e5`](http://github.com/koajs/koa/commit/a37a2e5eec8997661a35ca10210f1d9950976041)] - fix: compatible with node-v12.19.0 & earlier (#1590) (hyj1991 <<yeekwanvong@gmail.com>>)
7
+
8
+ 2.13.2 / 2021-09-24
9
+ ==================
10
+
11
+ **fixes**
12
+ * [[`04acf02`](http://github.com/koajs/koa/commit/04acf0281a5dcb3fd463d4c8537984c686d0b96f)] - fix: nodejs deprecated api <DEP0148> (#1585) (#1588) (hyj1991 <<yeekwanvong@gmail.com>>)
13
+
14
+ **others**
15
+ * [[`3435e78`](http://github.com/koajs/koa/commit/3435e7864a59cca2835ebaad96c4eda801b99b24)] - lint++ (jongleberry <<jonathanrichardong@gmail.com>>)
16
+ * [[`2cd6618`](http://github.com/koajs/koa/commit/2cd66182f46965f1d824c24826e85df251cca3d2)] - Fix grammar mistake (#1527) (Matheus Souza <<37983247+souzasmatheus@users.noreply.github.com>>)
17
+ * [[`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>>)
18
+ * [[`65113ca`](http://github.com/koajs/koa/commit/65113ca38af634e4b1002d5bc40917cc09a7b7c6)] - Fix jsdoc types for constructor (#1541) (Piotr Kuczynski <<piotr.kuczynski@gmail.com>>)
19
+ * [[`03e6317`](http://github.com/koajs/koa/commit/03e6317df24d2dce0c1f08869326149f766f1e41)] - :arrow_up: debug (jongleberry <<jonathanrichardong@gmail.com>>)
20
+ * [[`b37a2d0`](http://github.com/koajs/koa/commit/b37a2d09c137d9a553a0bdf8589b60c7f6425160)] - :arrow_up: eslint dependencies (jongleberry <<jonathanrichardong@gmail.com>>)
21
+ * [[`4a410cc`](http://github.com/koajs/koa/commit/4a410cc2fbd923868cac6a622f12cc652586abee)] - migrate assert.deepEqual => .deepStrictEqual (jongleberry <<jonathanrichardong@gmail.com>>)
22
+ * [[`4545b59`](http://github.com/koajs/koa/commit/4545b59aa521e377a4ebb0ccbb8abec01981fbf4)] - test: switch tests to jest (jongleberry <<jonathanrichardong@gmail.com>>)
23
+ * [[`596cfd5`](http://github.com/koajs/koa/commit/596cfd542ccd1d89d97453e29cf499d49a82e743)] - migrate assert.strict => .strictEqual (jongleberry <<jonathanrichardong@gmail.com>>)
24
+ * [[`be3e8b6`](http://github.com/koajs/koa/commit/be3e8b68ab58d469f0f450284528dbef32e2d7ba)] - test: switch to github actions (jongleberry <<jonathanrichardong@gmail.com>>)
25
+ * [[`a2570e3`](http://github.com/koajs/koa/commit/a2570e3ee622cfa5214c2f756ea03b3b7143dbf7)] - package: update bench scripts (jongleberry <<jonathanrichardong@gmail.com>>)
26
+ * [[`000acf0`](http://github.com/koajs/koa/commit/000acf06ab3e37006569addc8ace5c0a4365daa1)] - npm: enable package-lock (jongleberry <<jonathanrichardong@gmail.com>>)
27
+ * [[`47fdbca`](http://github.com/koajs/koa/commit/47fdbca8b1c3999c5726f54531f8b47640a65a6f)] - delete benchmarks (jongleberry <<jonathanrichardong@gmail.com>>)
28
+ * [[`0056f90`](http://github.com/koajs/koa/commit/0056f901e89fd0781067b2c9592fd5909f9ba94a)] - Create dependabot.yml (jongleberry <<jonathanrichardong@gmail.com>>)
29
+ * [[`698ce0a`](http://github.com/koajs/koa/commit/698ce0afbfac6480400625729a4b8fc4b4203fdc)] - test: fix typo in status.js (Ikko Ashimine <<eltociear@gmail.com>>)
30
+ * [[`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>>)
31
+
32
+ 2.13.1 / 2021-01-04
33
+ ==================
34
+
35
+ **fixes**
36
+ * [[`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>>)
37
+ * [[`68d97d6`](http://github.com/koajs/koa/commit/68d97d69e4536065504bf9ef1e348a66b3f35709)] - fix: fixed order of vulnerability disclosure addresses (niftylettuce <<niftylettuce@gmail.com>>)
38
+
39
+ **others**
40
+ * [[`b4398f5`](http://github.com/koajs/koa/commit/b4398f5d68f9546167419f394a686afdcb5e10e2)] - correct verb tense in doc (#1512) (Matan Shavit <<71092861+matanshavit@users.noreply.github.com>>)
41
+ * [[`39e1a5a`](http://github.com/koajs/koa/commit/39e1a5a380aa2bbc4e2d164e8e4bf37cfd512516)] - fixed multiple grammatical errors in docs. (#1497) (Hridayesh Sharma <<vyasriday7@gmail.com>>)
42
+ * [[`aeb5d19`](http://github.com/koajs/koa/commit/aeb5d1984dcc5f8e3386f8f9724807ae6f3aa1c4)] - docs: added niftylettuce@gmail.com to vulnerability disclosure (niftylettuce <<niftylettuce@gmail.com>>)
43
+ * [[`6e1093b`](http://github.com/koajs/koa/commit/6e1093be27b41135c8e67fce108743d54e9cab67)] - docs: remove babel from readme (#1494) (miwnwski <<m@iwnw.ski>>)
44
+ * [[`38cb591`](http://github.com/koajs/koa/commit/38cb591254ff5f65a04e8fb57be293afe697c46e)] - docs: update specific for auto response status (AlbertAZ1992 <<ziyuximing@163.com>>)
45
+ * [[`2224cd9`](http://github.com/koajs/koa/commit/2224cd9b6a648e7ac2eb27eac332e7d6de7db26c)] - docs: remove babel ref. (#1488) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
46
+ * [[`d51f983`](http://github.com/koajs/koa/commit/d51f98328c3b84493cc6bda0732aabb69e20e3a1)] - docs: fix assert example for response (#1489) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
47
+ * [[`f8b49b8`](http://github.com/koajs/koa/commit/f8b49b859363ad6c3d9ea5c11ee62341407ceafd)] - chore: fix grammatical and spelling errors in comments and tests (#1490) (Matt Kubej <<mkubej@gmail.com>>)
48
+ * [[`d1c9263`](http://github.com/koajs/koa/commit/d1c92638c95d799df2fdff5576b96fc43a62813f)] - deps: update depd >> v2.0.0 (#1482) (imed jaberi <<imed_jebari@hotmail.fr>>)
49
+
50
+ 2.13.0 / 2020-06-21
51
+ ==================
52
+
53
+ **features**
54
+ * [[`bbcde76`](http://github.com/koajs/koa/commit/bbcde76f5cb5b67bbcd3201791cf0ef648fd3a8b)] - feat: support esm (#1474) (ZYSzys <<zhangyongsheng@youzan.com>>)
55
+
56
+ **others**
57
+ * [[`20e58cf`](http://github.com/koajs/koa/commit/20e58cf3e4f20fc5d5886df1d0ac6dd8c33bd202)] - test: imporve coverage to 100% (dead-horse <<dead_horse@qq.com>>)
58
+ * [[`4a40d63`](http://github.com/koajs/koa/commit/4a40d633c4b4a203c6656078f9952ccef65c5875)] - build: use prepare instead of prepublish (dead-horse <<dead_horse@qq.com>>)
59
+ * [[`226ba8c`](http://github.com/koajs/koa/commit/226ba8c8e81e83da48e7bf137be3f146d03f40b8)] - build: use prepublish instead of prepack (dead-horse <<dead_horse@qq.com>>)
60
+
2
61
  2.12.1 / 2020-06-13
3
62
  ==================
4
63
 
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
 
package/dist/koa.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import mod from "../lib/application.js";
2
+
3
+ export default mod;
4
+ export const HttpError = mod.HttpError;
@@ -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
 
@@ -59,6 +59,8 @@ module.exports = class Application extends Emitter {
59
59
  this.context = Object.create(context);
60
60
  this.request = Object.create(request);
61
61
  this.response = Object.create(response);
62
+ // util.inspect.custom support for node 6+
63
+ /* istanbul ignore else */
62
64
  if (util.inspect.custom) {
63
65
  this[util.inspect.custom] = this.inspect;
64
66
  }
@@ -209,6 +211,15 @@ module.exports = class Application extends Emitter {
209
211
  const msg = err.stack || err.toString();
210
212
  console.error(`\n${msg.replace(/^/gm, ' ')}\n`);
211
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
+ }
212
223
  };
213
224
 
214
225
  /**
@@ -276,4 +287,5 @@ function respond(ctx) {
276
287
  * Make HttpError available to consumers of the library so that consumers don't
277
288
  * have a direct dependency upon `http-errors`
278
289
  */
290
+
279
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
@@ -433,6 +433,7 @@ module.exports = {
433
433
  * @return {boolean}
434
434
  * @api public
435
435
  */
436
+
436
437
  has(field) {
437
438
  return typeof this.res.hasHeader === 'function'
438
439
  ? this.res.hasHeader(field)
@@ -441,7 +442,7 @@ module.exports = {
441
442
  },
442
443
 
443
444
  /**
444
- * Set header `field` to `val`, or pass
445
+ * Set header `field` to `val` or pass
445
446
  * an object of header fields.
446
447
  *
447
448
  * Examples:
@@ -564,19 +565,22 @@ module.exports = {
564
565
  },
565
566
 
566
567
  /**
567
- * Flush any set headers, and begin the body
568
+ * Flush any set headers and begin the body
568
569
  */
570
+
569
571
  flushHeaders() {
570
572
  this.res.flushHeaders();
571
573
  }
572
574
  };
573
575
 
574
576
  /**
575
- * Custom inspection implementation for newer Node.js versions.
577
+ * Custom inspection implementation for node 6+.
576
578
  *
577
579
  * @return {Object}
578
580
  * @api public
579
581
  */
582
+
583
+ /* istanbul ignore else */
580
584
  if (util.inspect.custom) {
581
585
  module.exports[util.inspect.custom] = module.exports.inspect;
582
586
  }
package/package.json CHANGED
@@ -1,14 +1,32 @@
1
1
  {
2
2
  "name": "koa",
3
- "version": "2.12.1",
3
+ "version": "2.13.3",
4
4
  "description": "Koa web app framework",
5
5
  "main": "lib/application.js",
6
+ "exports": {
7
+ ".": {
8
+ "require": "./lib/application.js",
9
+ "import": "./dist/koa.mjs"
10
+ },
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"
23
+ },
6
24
  "scripts": {
7
- "test": "egg-bin test test",
8
- "test-cov": "egg-bin cov test",
9
- "lint": "eslint benchmarks lib test",
10
- "bench": "make -C benchmarks",
11
- "authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS"
25
+ "test": "jest --forceExit",
26
+ "lint": "eslint --ignore-path .gitignore .",
27
+ "authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS",
28
+ "build": "gen-esm-wrapper . ./dist/koa.mjs",
29
+ "prepare": "npm run build"
12
30
  },
13
31
  "repository": "koajs/koa",
14
32
  "keywords": [
@@ -27,9 +45,9 @@
27
45
  "content-disposition": "~0.5.2",
28
46
  "content-type": "^1.0.4",
29
47
  "cookies": "~0.8.0",
30
- "debug": "~3.1.0",
48
+ "debug": "^4.3.2",
31
49
  "delegates": "^1.0.0",
32
- "depd": "^1.1.2",
50
+ "depd": "^2.0.0",
33
51
  "destroy": "^1.0.4",
34
52
  "encodeurl": "^1.0.2",
35
53
  "escape-html": "^1.0.3",
@@ -38,7 +56,7 @@
38
56
  "http-errors": "^1.6.3",
39
57
  "is-generator-function": "^1.0.7",
40
58
  "koa-compose": "^4.1.0",
41
- "koa-convert": "^1.2.0",
59
+ "koa-convert": "^2.0.0",
42
60
  "on-finished": "^2.3.0",
43
61
  "only": "~0.0.2",
44
62
  "parseurl": "^1.3.2",
@@ -47,21 +65,25 @@
47
65
  "vary": "^1.1.2"
48
66
  },
49
67
  "devDependencies": {
50
- "egg-bin": "^4.13.0",
51
- "eslint": "^6.5.1",
68
+ "eslint": "^7.32.0",
52
69
  "eslint-config-koa": "^2.0.0",
53
- "eslint-config-standard": "^14.1.0",
70
+ "eslint-config-standard": "^16.0.3",
54
71
  "eslint-plugin-import": "^2.18.2",
55
- "eslint-plugin-node": "^10.0.0",
56
- "eslint-plugin-promise": "^4.2.1",
57
- "eslint-plugin-standard": "^4.0.1",
58
- "mm": "^2.5.0",
72
+ "eslint-plugin-node": "^11.1.0",
73
+ "eslint-plugin-promise": "^5.1.0",
74
+ "eslint-plugin-standard": "^5.0.0",
75
+ "gen-esm-wrapper": "^1.0.6",
76
+ "jest": "^27.0.6",
59
77
  "supertest": "^3.1.0"
60
78
  },
61
79
  "engines": {
62
80
  "node": "^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4"
63
81
  },
64
82
  "files": [
83
+ "dist",
65
84
  "lib"
66
- ]
85
+ ],
86
+ "jest": {
87
+ "testEnvironment": "node"
88
+ }
67
89
  }