koa 2.13.0 → 2.13.1
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 +18 -0
- package/Readme.md +1 -37
- package/lib/application.js +10 -0
- package/lib/request.js +10 -8
- package/lib/response.js +5 -2
- package/package.json +2 -2
package/History.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
2.13.1 / 2021-01-04
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
**fixes**
|
|
6
|
+
* [[`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>>)
|
|
7
|
+
* [[`68d97d6`](http://github.com/koajs/koa/commit/68d97d69e4536065504bf9ef1e348a66b3f35709)] - fix: fixed order of vulnerability disclosure addresses (niftylettuce <<niftylettuce@gmail.com>>)
|
|
8
|
+
|
|
9
|
+
**others**
|
|
10
|
+
* [[`b4398f5`](http://github.com/koajs/koa/commit/b4398f5d68f9546167419f394a686afdcb5e10e2)] - correct verb tense in doc (#1512) (Matan Shavit <<71092861+matanshavit@users.noreply.github.com>>)
|
|
11
|
+
* [[`39e1a5a`](http://github.com/koajs/koa/commit/39e1a5a380aa2bbc4e2d164e8e4bf37cfd512516)] - fixed multiple grammatical errors in docs. (#1497) (Hridayesh Sharma <<vyasriday7@gmail.com>>)
|
|
12
|
+
* [[`aeb5d19`](http://github.com/koajs/koa/commit/aeb5d1984dcc5f8e3386f8f9724807ae6f3aa1c4)] - docs: added niftylettuce@gmail.com to vulnerability disclosure (niftylettuce <<niftylettuce@gmail.com>>)
|
|
13
|
+
* [[`6e1093b`](http://github.com/koajs/koa/commit/6e1093be27b41135c8e67fce108743d54e9cab67)] - docs: remove babel from readme (#1494) (miwnwski <<m@iwnw.ski>>)
|
|
14
|
+
* [[`38cb591`](http://github.com/koajs/koa/commit/38cb591254ff5f65a04e8fb57be293afe697c46e)] - docs: update specific for auto response status (AlbertAZ1992 <<ziyuximing@163.com>>)
|
|
15
|
+
* [[`2224cd9`](http://github.com/koajs/koa/commit/2224cd9b6a648e7ac2eb27eac332e7d6de7db26c)] - docs: remove babel ref. (#1488) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
|
|
16
|
+
* [[`d51f983`](http://github.com/koajs/koa/commit/d51f98328c3b84493cc6bda0732aabb69e20e3a1)] - docs: fix assert example for response (#1489) (Imed Jaberi <<imed_jebari@hotmail.fr>>)
|
|
17
|
+
* [[`f8b49b8`](http://github.com/koajs/koa/commit/f8b49b859363ad6c3d9ea5c11ee62341407ceafd)] - chore: fix grammatical and spelling errors in comments and tests (#1490) (Matt Kubej <<mkubej@gmail.com>>)
|
|
18
|
+
* [[`d1c9263`](http://github.com/koajs/koa/commit/d1c92638c95d799df2fdff5576b96fc43a62813f)] - deps: update depd >> v2.0.0 (#1482) (imed jaberi <<imed_jebari@hotmail.fr>>)
|
|
19
|
+
|
|
2
20
|
2.13.0 / 2020-06-21
|
|
3
21
|
==================
|
|
4
22
|
|
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/lib/application.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
|
445
|
+
* Set header `field` to `val` or pass
|
|
445
446
|
* an object of header fields.
|
|
446
447
|
*
|
|
447
448
|
* Examples:
|
|
@@ -564,8 +565,9 @@ module.exports = {
|
|
|
564
565
|
},
|
|
565
566
|
|
|
566
567
|
/**
|
|
567
|
-
* Flush any set headers
|
|
568
|
+
* Flush any set headers and begin the body
|
|
568
569
|
*/
|
|
570
|
+
|
|
569
571
|
flushHeaders() {
|
|
570
572
|
this.res.flushHeaders();
|
|
571
573
|
}
|
|
@@ -577,6 +579,7 @@ module.exports = {
|
|
|
577
579
|
* @return {Object}
|
|
578
580
|
* @api public
|
|
579
581
|
*/
|
|
582
|
+
|
|
580
583
|
/* istanbul ignore else */
|
|
581
584
|
if (util.inspect.custom) {
|
|
582
585
|
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.
|
|
3
|
+
"version": "2.13.1",
|
|
4
4
|
"description": "Koa web app framework",
|
|
5
5
|
"main": "lib/application.js",
|
|
6
6
|
"exports": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"cookies": "~0.8.0",
|
|
39
39
|
"debug": "~3.1.0",
|
|
40
40
|
"delegates": "^1.0.0",
|
|
41
|
-
"depd": "^
|
|
41
|
+
"depd": "^2.0.0",
|
|
42
42
|
"destroy": "^1.0.4",
|
|
43
43
|
"encodeurl": "^1.0.2",
|
|
44
44
|
"escape-html": "^1.0.3",
|