From de167f95e6ed47445ff3bbb73045d49c3aa6056d Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Thu, 25 Jan 2024 11:02:34 +0100 Subject: [PATCH 1/7] feat: bump hono to v3.12.7, add customer err tests for compress middleware --- package.json | 2 +- test/server.test.ts | 91 +++++++++++++++++++++++++++++++++++++++++++-- yarn.lock | 8 ++-- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bf6ae26..732dd32 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@types/supertest": "^2.0.12", "@whatwg-node/fetch": "^0.9.14", "eslint": "^8.55.0", - "hono": "^3.11.7", + "hono": "3.12.7", "jest": "^29.6.1", "np": "^7.7.0", "publint": "^0.1.16", diff --git a/test/server.test.ts b/test/server.test.ts index a7a111c..66e6b99 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -70,10 +70,11 @@ describe('Basic', () => { it('Should return 500 response - GET /invalid', async () => { const res = await request(server).get('/invalid') expect(res.status).toBe(500) - expect(res.headers['content-type']).toBe('text/plain') + expect(res.headers['content-type']).toEqual('text/plain;charset=UTF-8') }) - it('Should return 200 response - GET /ponyfill', async () => { + // it fails with hono 3.12.7 + it.skip('Should return 200 response - GET /ponyfill', async () => { const res = await request(server).get('/ponyfill') expect(res.status).toBe(200) expect(res.headers['content-type']).toMatch(/text\/plain/) @@ -500,10 +501,22 @@ describe('HTTP2', () => { }) }) -describe('Hono compression', () => { +describe('Hono compression default gzip', () => { const app = new Hono() app.use('*', compress()) + app.notFound((c) => { + return c.text('Custom NotFound', 404) + }) + + app.onError((_, c) => { + return c.text('Custom Error!', 500) + }) + + app.get('/error', () => { + throw new Error() + }) + app.get('/one', async (c) => { let body = 'one' @@ -513,13 +526,83 @@ describe('Hono compression', () => { return c.text(body) }) - it('Should return 200 response - GET /one', async () => { + it('should return 200 response - GET /one', async () => { const server = createAdaptorServer(app) const res = await request(server).get('/one') expect(res.status).toBe(200) expect(res.headers['content-type']).toMatch(/text\/plain/) expect(res.headers['content-encoding']).toMatch(/gzip/) }) + + it('should return 404 Custom NotFound', async () => { + const server = createAdaptorServer(app) + const res = await request(server).get('/err') + expect(res.status).toBe(404) + expect(res.text).toEqual('Custom NotFound') + expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') + expect(res.headers['content-encoding']).toMatch(/gzip/) + }) + + it('should return 500 Custom Error!', async () => { + const server = createAdaptorServer(app) + const res = await request(server).get('/error') + expect(res.status).toBe(500) + expect(res.text).toEqual('Custom Error!') + expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') + expect(res.headers['content-encoding']).toMatch(/gzip/) + }) +}) + +describe('Hono compression deflate', () => { + const app = new Hono() + app.use('*', compress( { encoding: 'deflate'})) + + app.notFound((c) => { + return c.text('Custom NotFound', 404) + }) + + app.onError((_, c) => { + return c.text('Custom Error!', 500) + }) + + app.get('/error', () => { + throw new Error() + }) + + app.get('/one', async (c) => { + let body = 'one' + + for (let index = 0; index < 1000 * 1000; index++) { + body += ' one' + } + return c.text(body) + }) + + it('should return 200 response - GET /one', async () => { + const server = createAdaptorServer(app) + const res = await request(server).get('/one') + expect(res.status).toBe(200) + expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-encoding']).toMatch(/deflate/) + }) + + it('should return 404 Custom NotFound', async () => { + const server = createAdaptorServer(app) + const res = await request(server).get('/err') + expect(res.status).toBe(404) + expect(res.text).toEqual('Custom NotFound') + expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') + expect(res.headers['content-encoding']).toMatch(/deflate/) + }) + + it('should return 500 Custom Error!', async () => { + const server = createAdaptorServer(app) + const res = await request(server).get('/error') + expect(res.status).toBe(500) + expect(res.text).toEqual('Custom Error!') + expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') + expect(res.headers['content-encoding']).toMatch(/deflate/) + }) }) describe('set child response to c.res', () => { diff --git a/yarn.lock b/yarn.lock index 0433387..e201646 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2924,10 +2924,10 @@ hexoid@^1.0.0: resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18" integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g== -hono@^3.11.7: - version "3.11.7" - resolved "https://registry.yarnpkg.com/hono/-/hono-3.11.7.tgz#e44f8aa3a18f19775304328bde6f559f7a02447f" - integrity sha512-TcfAq7IdipF+9coxnuzYlSSBXbm9mTyWjjagLCv/2ampboNcKJdi+XCK5G48mHQtpI5+9Rj3J4FfcGgw9vzIww== +hono@3.12.7: + version "3.12.7" + resolved "https://registry.yarnpkg.com/hono/-/hono-3.12.7.tgz#76be7d8a2f43ef29bba47e663b1adfba264a3281" + integrity sha512-jfyIoE8D5I1PGj0tXAGqpQ2miAWBBuHFjJsWjh0hbBVludQ8QO4lF6KTbPvjMi4venp8Q6DyMoJ51CwP6L5LNA== hosted-git-info@^2.1.4: version "2.8.9" From 6b632310cba8e4b922f5c1746d28c908d2278de1 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Tue, 30 Jan 2024 09:21:53 +0100 Subject: [PATCH 2/7] feat: fix UTF-8 issue, refactor tests, bump hono to 3.12.8 --- package.json | 2 +- src/response.ts | 2 +- src/utils.ts | 2 +- test/server.test.ts | 65 ++++++++++++++++++++++----------------------- yarn.lock | 8 +++--- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 732dd32..c20eb7e 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@types/supertest": "^2.0.12", "@whatwg-node/fetch": "^0.9.14", "eslint": "^8.55.0", - "hono": "3.12.7", + "hono": "^3.12.8", "jest": "^29.6.1", "np": "^7.7.0", "publint": "^0.1.16", diff --git a/src/response.ts b/src/response.ts index 1a4ef07..2c68b8e 100644 --- a/src/response.ts +++ b/src/response.ts @@ -34,7 +34,7 @@ export class Response { } if (typeof body === 'string' || body instanceof ReadableStream) { - let headers = (init?.headers || { 'content-type': 'text/plain;charset=UTF-8' }) as + let headers = (init?.headers || { 'content-type': 'text/plain; charset=UTF-8' }) as | Record | Headers | OutgoingHttpHeaders diff --git a/src/utils.ts b/src/utils.ts index 937c3c6..33ed095 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -53,7 +53,7 @@ export const buildOutgoingHttpHeaders = (headers: Headers): OutgoingHttpHeaders if (cookies.length > 0) { res['set-cookie'] = cookies } - res['content-type'] ??= 'text/plain;charset=UTF-8' + res['content-type'] ??= 'text/plain; charset=UTF-8' return res } diff --git a/test/server.test.ts b/test/server.test.ts index 66e6b99..c3cf9bc 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -38,7 +38,7 @@ describe('Basic', () => { it('Should return 200 response - GET /', async () => { const res = await request(server).get('/') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hello! Node!') }) @@ -51,7 +51,7 @@ describe('Basic', () => { it('Should return 200 response - GET /user-agent', async () => { const res = await request(server).get('/user-agent').set('user-agent', 'Hono') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hono') }) @@ -70,14 +70,13 @@ describe('Basic', () => { it('Should return 500 response - GET /invalid', async () => { const res = await request(server).get('/invalid') expect(res.status).toBe(500) - expect(res.headers['content-type']).toEqual('text/plain;charset=UTF-8') + expect(res.headers['content-type']).toEqual('text/plain') }) - // it fails with hono 3.12.7 - it.skip('Should return 200 response - GET /ponyfill', async () => { + it('Should return 200 response - GET /ponyfill', async () => { const res = await request(server).get('/ponyfill') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Pony') }) }) @@ -189,28 +188,28 @@ describe('Response body', () => { it('Should return JSON body', async () => { const res = await request(server).get('/json') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') expect(JSON.parse(res.text)).toEqual({ foo: 'bar' }) }) it('Should return JSON body from /json-async', async () => { const res = await request(server).get('/json-async') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') expect(JSON.parse(res.text)).toEqual({ foo: 'async' }) }) it('Should return HTML', async () => { const res = await request(server).get('/html') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/html/) + expect(res.headers['content-type']).toMatch('text/html') expect(res.text).toBe('

Hello!

') }) it('Should return HTML from /html-async', async () => { const res = await request(server).get('/html-async') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/html/) + expect(res.headers['content-type']).toMatch('text/html') expect(res.text).toBe('

Hello!

') }) }) @@ -235,14 +234,14 @@ describe('Response body', () => { it('Should return JSON body from /json-blob', async () => { const res = await request(server).get('/json-blob') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') expect(JSON.parse(res.text)).toEqual({ foo: 'blob' }) }) it('Should return JSON body from /json-buffer', async () => { const res = await request(server).get('/json-buffer') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') expect(JSON.parse(res.text)).toEqual({ foo: 'buffer' }) }) }) @@ -394,7 +393,7 @@ describe('Stream and non-stream response', () => { const res = await request(server).get('/json') expect(res.status).toBe(200) expect(res.headers['content-length']).toMatch('13') - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') expect(JSON.parse(res.text)).toEqual({ foo: 'bar' }) }) @@ -402,7 +401,7 @@ describe('Stream and non-stream response', () => { const res = await request(server).get('/text') expect(res.status).toBe(200) expect(res.headers['content-length']).toMatch('6') - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hello!') }) @@ -410,8 +409,8 @@ describe('Stream and non-stream response', () => { const res = await request(server).get('/json-stream') expect(res.status).toBe(200) expect(res.headers['content-length']).toBeUndefined() - expect(res.headers['content-type']).toMatch(/application\/json/) - expect(res.headers['transfer-encoding']).toMatch(/chunked/) + expect(res.headers['content-type']).toMatch('application/json') + expect(res.headers['transfer-encoding']).toMatch('chunked') expect(JSON.parse(res.text)).toEqual({ foo: 'bar' }) }) @@ -429,8 +428,8 @@ describe('Stream and non-stream response', () => { }) expect(res.status).toBe(200) expect(res.headers['content-length']).toBeUndefined() - expect(res.headers['content-type']).toMatch(/text\/event-stream/) - expect(res.headers['transfer-encoding']).toMatch(/chunked/) + expect(res.headers['content-type']).toMatch('text/event-stream') + expect(res.headers['transfer-encoding']).toMatch('chunked') }) it('Should return error - stream without app crashing', async () => { @@ -455,7 +454,7 @@ describe('SSL', () => { it('Should return 200 response - GET /', async () => { const res = await request(server).get('/').trustLocalhost() expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hello! Node!') }) }) @@ -463,10 +462,10 @@ describe('SSL', () => { describe('HTTP2', () => { const app = new Hono() app.get('/', (c) => c.text('Hello! Node!')) - app.get('/headers', (c) => { + app.get('/headers', (c) => { // call newRequestFromIncoming c.req.header('Accept') - return c.text('Hello! Node!') + return c.text('Hello! Node!') }) app.get('/url', (c) => c.text(c.req.url)) @@ -479,7 +478,7 @@ describe('HTTP2', () => { // @ts-expect-error: @types/supertest is not updated yet const res = await request(server, { http2: true }).get('/').trustLocalhost() expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hello! Node!') }) @@ -487,7 +486,7 @@ describe('HTTP2', () => { // @ts-expect-error: @types/supertest is not updated yet const res = await request(server, { http2: true }).get('/headers').trustLocalhost() expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(res.text).toBe('Hello! Node!') }) @@ -496,7 +495,7 @@ describe('HTTP2', () => { // @ts-expect-error: @types/supertest is not updated yet const res = await request(server, { http2: true }).get('/url').trustLocalhost() expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) + expect(res.headers['content-type']).toMatch('text/plain') expect(new URL(res.text).hostname).toBe('127.0.0.1') }) }) @@ -530,8 +529,8 @@ describe('Hono compression default gzip', () => { const server = createAdaptorServer(app) const res = await request(server).get('/one') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) - expect(res.headers['content-encoding']).toMatch(/gzip/) + expect(res.headers['content-type']).toMatch('text/plain') + expect(res.headers['content-encoding']).toMatch('gzip') }) it('should return 404 Custom NotFound', async () => { @@ -540,7 +539,7 @@ describe('Hono compression default gzip', () => { expect(res.status).toBe(404) expect(res.text).toEqual('Custom NotFound') expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') - expect(res.headers['content-encoding']).toMatch(/gzip/) + expect(res.headers['content-encoding']).toMatch('gzip') }) it('should return 500 Custom Error!', async () => { @@ -549,7 +548,7 @@ describe('Hono compression default gzip', () => { expect(res.status).toBe(500) expect(res.text).toEqual('Custom Error!') expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') - expect(res.headers['content-encoding']).toMatch(/gzip/) + expect(res.headers['content-encoding']).toMatch('gzip') }) }) @@ -582,8 +581,8 @@ describe('Hono compression deflate', () => { const server = createAdaptorServer(app) const res = await request(server).get('/one') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/text\/plain/) - expect(res.headers['content-encoding']).toMatch(/deflate/) + expect(res.headers['content-type']).toMatch('text/plain') + expect(res.headers['content-encoding']).toMatch('deflate') }) it('should return 404 Custom NotFound', async () => { @@ -592,7 +591,7 @@ describe('Hono compression deflate', () => { expect(res.status).toBe(404) expect(res.text).toEqual('Custom NotFound') expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') - expect(res.headers['content-encoding']).toMatch(/deflate/) + expect(res.headers['content-encoding']).toMatch('deflate') }) it('should return 500 Custom Error!', async () => { @@ -601,7 +600,7 @@ describe('Hono compression deflate', () => { expect(res.status).toBe(500) expect(res.text).toEqual('Custom Error!') expect(res.headers['content-type']).toEqual('text/plain; charset=UTF-8') - expect(res.headers['content-encoding']).toMatch(/deflate/) + expect(res.headers['content-encoding']).toMatch('deflate') }) }) @@ -621,6 +620,6 @@ describe('set child response to c.res', () => { const server = createAdaptorServer(app) const res = await request(server).get('/json') expect(res.status).toBe(200) - expect(res.headers['content-type']).toMatch(/application\/json/) + expect(res.headers['content-type']).toMatch('application/json') }) }) diff --git a/yarn.lock b/yarn.lock index e201646..2b35c64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2924,10 +2924,10 @@ hexoid@^1.0.0: resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18" integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g== -hono@3.12.7: - version "3.12.7" - resolved "https://registry.yarnpkg.com/hono/-/hono-3.12.7.tgz#76be7d8a2f43ef29bba47e663b1adfba264a3281" - integrity sha512-jfyIoE8D5I1PGj0tXAGqpQ2miAWBBuHFjJsWjh0hbBVludQ8QO4lF6KTbPvjMi4venp8Q6DyMoJ51CwP6L5LNA== +hono@^3.12.8: + version "3.12.8" + resolved "https://registry.yarnpkg.com/hono/-/hono-3.12.8.tgz#7c137aa6ac7bcd2aec3f55b9596d71e97081963a" + integrity sha512-vnOEIRdqsp4uHE/dkOBr9EYmTsR86sD/FyG2xhfAQzR9udDRglN1nuO7SGc/7U3HfSorc6PSCNGN6upnVtCmfg== hosted-git-info@^2.1.4: version "2.8.9" From 295a77b358ea7c1ebf1b107aab1e9b01d38ff9a8 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Tue, 30 Jan 2024 21:27:16 +0100 Subject: [PATCH 3/7] fix: added prettier dev dep and formating script, code format --- package.json | 5 ++++- test/server.test.ts | 2 +- yarn.lock | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c20eb7e..8db40c3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,9 @@ "prerelease": "yarn build && yarn test", "release": "np", "lint": "eslint --ext js,ts src test", - "lint:fix": "eslint --ext js,ts src test --fix" + "lint:fix": "eslint --ext js,ts src test --fix", + "format": "prettier --check \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\"", + "format:fix": "prettier --write \"src/**/*.{js,ts}\" \"test/**/*.{js,ts}\"" }, "license": "MIT", "repository": { @@ -71,6 +73,7 @@ "hono": "^3.12.8", "jest": "^29.6.1", "np": "^7.7.0", + "prettier": "3.2.4", "publint": "^0.1.16", "supertest": "^6.3.3", "ts-jest": "^29.1.1", diff --git a/test/server.test.ts b/test/server.test.ts index c3cf9bc..66f5d77 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -554,7 +554,7 @@ describe('Hono compression default gzip', () => { describe('Hono compression deflate', () => { const app = new Hono() - app.use('*', compress( { encoding: 'deflate'})) + app.use('*', compress({ encoding: 'deflate' })) app.notFound((c) => { return c.text('Custom NotFound', 404) diff --git a/yarn.lock b/yarn.lock index 2b35c64..2f92d14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4808,6 +4808,11 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== +prettier@3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz#4723cadeac2ce7c9227de758e5ff9b14e075f283" + integrity sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ== + pretty-format@^29.0.0, pretty-format@^29.0.3: version "29.0.3" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.0.3.tgz#23d5f8cabc9cbf209a77d49409d093d61166a811" From c74dbd5605cb51eb7ab9a12fe2a99e343d888f27 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Wed, 31 Jan 2024 09:49:52 +0100 Subject: [PATCH 4/7] updated yarn.lock with prettier --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 1e2609a..99aad52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4808,7 +4808,7 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== -prettier@^3.2.4: +prettier@3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz#4723cadeac2ce7c9227de758e5ff9b14e075f283" integrity sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ== From 0885eabf4d271f286421b62ee63b8bbd331c40fd Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Wed, 31 Jan 2024 16:14:30 +0100 Subject: [PATCH 5/7] refactor utils --- src/utils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 8117fbb..4874906 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -46,11 +46,7 @@ export const buildOutgoingHttpHeaders = (headers: Headers): OutgoingHttpHeaders const cookies = [] for (const [k, v] of headers) { - if (k === 'set-cookie') { - cookies.push(v) - } else { - res[k] = v - } + k === 'set-cookie' ? cookies.push(v) : (res[k] = v) } if (cookies.length > 0) { res['set-cookie'] = cookies From d905e6c1a0e4078094e721c74d509e32681aca30 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Thu, 1 Feb 2024 08:32:10 +0100 Subject: [PATCH 6/7] Revert "refactor utils" This reverts commit 0885eabf4d271f286421b62ee63b8bbd331c40fd. --- src/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 4874906..8117fbb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -46,7 +46,11 @@ export const buildOutgoingHttpHeaders = (headers: Headers): OutgoingHttpHeaders const cookies = [] for (const [k, v] of headers) { - k === 'set-cookie' ? cookies.push(v) : (res[k] = v) + if (k === 'set-cookie') { + cookies.push(v) + } else { + res[k] = v + } } if (cookies.length > 0) { res['set-cookie'] = cookies From 39995296d0d8b002ee2e20edcc58e47177f7ac19 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Thu, 1 Feb 2024 08:38:58 +0100 Subject: [PATCH 7/7] fix: add caret range for prettier --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bebaa6a..f3e572b 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "hono": "^3.12.8", "jest": "^29.6.1", "np": "^7.7.0", - "prettier": "3.2.4", + "prettier": "^3.2.4", "publint": "^0.1.16", "supertest": "^6.3.3", "ts-jest": "^29.1.1", diff --git a/yarn.lock b/yarn.lock index 99aad52..1e2609a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4808,7 +4808,7 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== -prettier@3.2.4: +prettier@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.4.tgz#4723cadeac2ce7c9227de758e5ff9b14e075f283" integrity sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==