diff --git a/__tests__/request/header.js b/__tests__/request/header.js index dd5b696c0..f495da243 100644 --- a/__tests__/request/header.js +++ b/__tests__/request/header.js @@ -12,7 +12,7 @@ describe('req.header', () => { it('should set the request header object', () => { const req = request(); - req.header = {'X-Custom-Headerfield': 'Its one header, with headerfields'}; + req.header = { 'X-Custom-Headerfield': 'Its one header, with headerfields' }; assert.deepStrictEqual(req.header, req.req.headers); }); }); diff --git a/__tests__/request/headers.js b/__tests__/request/headers.js index c91f14453..160ac8573 100644 --- a/__tests__/request/headers.js +++ b/__tests__/request/headers.js @@ -12,7 +12,7 @@ describe('req.headers', () => { it('should set the request header object', () => { const req = request(); - req.headers = {'X-Custom-Headerfield': 'Its one header, with headerfields'}; + req.headers = { 'X-Custom-Headerfield': 'Its one header, with headerfields' }; assert.deepStrictEqual(req.headers, req.req.headers); }); }); diff --git a/__tests__/request/host.js b/__tests__/request/host.js index eb3cf629e..c64b4af9a 100644 --- a/__tests__/request/host.js +++ b/__tests__/request/host.js @@ -21,8 +21,8 @@ describe('req.host', () => { describe('when less then HTTP/2', () => { it('should not use :authority header', () => { const req = request({ - 'httpVersionMajor': 1, - 'httpVersion': '1.1' + httpVersionMajor: 1, + httpVersion: '1.1' }); req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; @@ -33,8 +33,8 @@ describe('req.host', () => { describe('when HTTP/2', () => { it('should use :authority header', () => { const req = request({ - 'httpVersionMajor': 2, - 'httpVersion': '2.0' + httpVersionMajor: 2, + httpVersion: '2.0' }); req.header[':authority'] = 'foo.com:3000'; req.header.host = 'bar.com:8000'; @@ -43,8 +43,8 @@ describe('req.host', () => { it('should use host header as fallback', () => { const req = request({ - 'httpVersionMajor': 2, - 'httpVersion': '2.0' + httpVersionMajor: 2, + httpVersion: '2.0' }); req.header.host = 'bar.com:8000'; assert.strictEqual(req.host, 'bar.com:8000'); @@ -62,8 +62,8 @@ describe('req.host', () => { it('should be ignored on HTTP/2', () => { const req = request({ - 'httpVersionMajor': 2, - 'httpVersion': '2.0' + httpVersionMajor: 2, + httpVersion: '2.0' }); req.header['x-forwarded-host'] = 'proxy.com:8080'; req.header[':authority'] = 'foo.com:3000'; @@ -83,8 +83,8 @@ describe('req.host', () => { it('should be used on HTTP/2', () => { const req = request({ - 'httpVersionMajor': 2, - 'httpVersion': '2.0' + httpVersionMajor: 2, + httpVersion: '2.0' }); req.app.proxy = true; req.header['x-forwarded-host'] = 'proxy.com:8080'; diff --git a/__tests__/response/attachment.js b/__tests__/response/attachment.js index 0cbe2576f..be58d7d8f 100644 --- a/__tests__/response/attachment.js +++ b/__tests__/response/attachment.js @@ -37,13 +37,13 @@ describe('ctx.attachment([filename])', () => { app.use((ctx, next) => { ctx.attachment('path/to/include-no-ascii-char-中文名-ok.json'); - ctx.body = {foo: 'bar'}; + ctx.body = { foo: 'bar' }; }); return request(app.callback()) .get('/') .expect('content-disposition', 'attachment; filename="include-no-ascii-char-???-ok.json"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.json') - .expect({foo: 'bar'}) + .expect({ foo: 'bar' }) .expect(200); }); }); diff --git a/__tests__/response/flushHeaders.js b/__tests__/response/flushHeaders.js index 0f205cb9a..326dc2a04 100644 --- a/__tests__/response/flushHeaders.js +++ b/__tests__/response/flushHeaders.js @@ -91,7 +91,7 @@ describe('ctx.flushHeaders()', () => { app.use(ctx => { ctx.type = 'json'; ctx.status = 200; - ctx.headers['Link'] = '; as=style; rel=preload, ; rel=preconnect; crossorigin'; + ctx.headers.Link = '; as=style; rel=preload, ; rel=preconnect; crossorigin'; const stream = ctx.body = new PassThrough(); ctx.flushHeaders(); @@ -134,7 +134,7 @@ describe('ctx.flushHeaders()', () => { app.use(ctx => { ctx.type = 'json'; ctx.status = 200; - ctx.headers['Link'] = '; as=style; rel=preload, ; rel=preconnect; crossorigin'; + ctx.headers.Link = '; as=style; rel=preload, ; rel=preconnect; crossorigin'; ctx.length = 20; ctx.flushHeaders(); const stream = ctx.body = new PassThrough(); diff --git a/__tests__/response/set.js b/__tests__/response/set.js index 0d338fff5..9ec601915 100644 --- a/__tests__/response/set.js +++ b/__tests__/response/set.js @@ -25,8 +25,8 @@ describe('ctx.set(name, val)', () => { it('should set a field value of array', () => { const ctx = context(); - ctx.set('x-foo', ['foo', 'bar', 123 ]); - assert.deepStrictEqual(ctx.response.header['x-foo'], [ 'foo', 'bar', '123' ]); + ctx.set('x-foo', ['foo', 'bar', 123]); + assert.deepStrictEqual(ctx.response.header['x-foo'], ['foo', 'bar', '123']); }); }); diff --git a/__tests__/response/status.js b/__tests__/response/status.js index 3e1f13866..e3d055e7f 100644 --- a/__tests__/response/status.js +++ b/__tests__/response/status.js @@ -46,8 +46,8 @@ describe('res.status=', () => { describe('and HTTP/2', () => { it('should not set the status message', () => { const res = response({ - 'httpVersionMajor': 2, - 'httpVersion': '2.0' + httpVersionMajor: 2, + httpVersion: '2.0' }); res.status = 200; assert(!res.res.statusMessage); diff --git a/package-lock.json b/package-lock.json index 1c86f3469..9e634a01b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "http-errors": "^1.6.3", "is-generator-function": "^1.0.7", "koa-compose": "^4.1.0", - "koa-convert": "^1.2.0", + "koa-convert": "^2.0.0", "on-finished": "^2.3.0", "only": "~0.0.2", "parseurl": "^1.3.2", @@ -1246,11 +1246,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" - }, "node_modules/anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -4423,23 +4418,15 @@ "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==" }, "node_modules/koa-convert": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-1.2.0.tgz", - "integrity": "sha1-2kCHXfSd4FOQmNFwC1CCDOvNIdA=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz", + "integrity": "sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==", "dependencies": { "co": "^4.6.0", - "koa-compose": "^3.0.0" + "koa-compose": "^4.1.0" }, "engines": { - "node": ">= 4" - } - }, - "node_modules/koa-convert/node_modules/koa-compose": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz", - "integrity": "sha1-qFzLQLfZhtjlo0Wzoazo6rz1Tec=", - "dependencies": { - "any-promise": "^1.1.0" + "node": ">= 10" } }, "node_modules/leven": { @@ -7239,11 +7226,6 @@ "color-convert": "^2.0.1" } }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" - }, "anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -9653,22 +9635,12 @@ "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==" }, "koa-convert": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-1.2.0.tgz", - "integrity": "sha1-2kCHXfSd4FOQmNFwC1CCDOvNIdA=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz", + "integrity": "sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==", "requires": { "co": "^4.6.0", - "koa-compose": "^3.0.0" - }, - "dependencies": { - "koa-compose": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz", - "integrity": "sha1-qFzLQLfZhtjlo0Wzoazo6rz1Tec=", - "requires": { - "any-promise": "^1.1.0" - } - } + "koa-compose": "^4.1.0" } }, "leven": {