chore(april-fool): change `hono is cool` to `hono is hot` (#4035)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* april-fool: change `hono is cool` to `hono is hot` * chore: format * fix: test * chore * Update accept.test.ts * chore * chore * chore * chore * chore * chore * chore * all changed * chore: format
authored by EdamAmex · committed by GitHub · parent 2c3e1ae · Browse files · 20 files·+50 added−57 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
20 files+50 added−57 removed
- tests:+42 added−48 removed
- other:+8 added−9 removed
Provenance
- Commit
882e75a- Tree
e8f6c56- Author
EdamAmex <121654029+EdamAme-x@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
2c3e1ae
20 files changed+50 added−57 removed
modified:docs/CONTRIBUTING.md+1 added-1 removed
14 unmodified lines1516171819192021222333 unmodified lines14 unmodified linesI want to write the code as I like.So, if you propose great ideas, but I do not appropriate them, the idea may not be accepted.
Although, don't worry!Hono is tested well, polished by the contributors, and used by many developers. And I'll try my best to make Hono cool, beautiful, and ultrafast.Hono is tested well, polished by the contributors, and used by many developers. And I'll try my best to make Hono cool and hot, beautiful, and ultrafast.
## Installing dependencies
The `honojs/hono` project uses [Bun](https://bun.sh/) as its package manager. Developers should install Bun.33 unmodified linesmodified:runtime-tests/deno/middleware.test.tsx+2 added-2 removed
11 unmodified lines12 Deno.test('Basic Auth Middleware', async () => {13 const app = new Hono()14 15 const username = 'hono'16- const password = 'acoolproject'16+ const password = 'ahotproject'17 18 app.use(19 '/auth/*',20 basicAuth({7 unmodified lines28 const res = await app.request('http://localhost/auth/a')29 assertEquals(res.status, 401)30 assertEquals(await res.text(), 'Unauthorized')31 32- const credential = 'aG9ubzphY29vbHByb2plY3Q='32+ const credential = 'aG9ubzphaG90cHJvamVjdA=='33 34 const req = new Request('http://localhost/auth/a')35 req.headers.set('Authorization', `Basic ${credential}`)36 const resOK = await app.request(req)150 unmodified linesmodified:runtime-tests/lambda-edge/index.test.ts-1 removed
1-/* eslint-disable quotes */1 import type {2 Callback,3 CloudFrontConfig,4 CloudFrontRequest,1130 unmodified linesmodified:src/adapter/cloudflare-pages/handler.test.ts+5 added-5 removed
16 unmodified lines17 data: {},18 env: {19 ...context.env,20 ASSETS: { fetch: vi.fn(), ...context.env?.ASSETS },21- TOKEN: context.env?.TOKEN ?? 'HONOISCOOL',21+ TOKEN: context.env?.TOKEN ?? 'HONOISHOT',22 },23 functionPath: '_worker.js',24 next: vi.fn(),25 params: {},8 unmodified lines34 it('Should return 200 response', async () => {35 const request = new Request('http://localhost/api/foo')36 const env = {37 ASSETS: { fetch },38- TOKEN: 'HONOISCOOL',38+ TOKEN: 'HONOISHOT',39 }40 const waitUntil = vi.fn()41 const passThroughOnException = vi.fn()42 const eventContext = createEventContext({15 unmodified lines58 { waitUntil, passThroughOnException }59 )60 expect(res.status).toBe(200)61 expect(await res.json()).toEqual({62- TOKEN: 'HONOISCOOL',62+ TOKEN: 'HONOISHOT',63 requestURL: 'http://localhost/api/foo',64 })65 })66 182 unmodified lines249 const assetsFetch = vi.fn().mockResolvedValue(new Response('foo.png'))250 const request = new Request('http://localhost/foo.png')251 const env = {252 ASSETS: { fetch: assetsFetch },253- TOKEN: 'HONOISCOOL',253+ TOKEN: 'HONOISHOT',254 }255 256 const eventContext = createEventContext({ request, env })257 const app = new Hono<Env>()10 unmodified lines268 const assetsFetch = vi.fn().mockResolvedValue(new Response(null, { status: 404 }))269 const request = new Request('http://localhost/foo.png')270 const env = {271 ASSETS: { fetch: assetsFetch },272- TOKEN: 'HONOISCOOL',272+ TOKEN: 'HONOISHOT',273 }274 275 const eventContext = createEventContext({ request, env })276 const app = new Hono<Env>()8 unmodified linesmodified:src/adapter/service-worker/handler.test.ts-1 removed
8 unmodified lines9101112131314151678 unmodified lines8 unmodified lines 'fetch', function fetch(this: undefined | typeof globalThis, arg0: string | Request) { if (this !== globalThis) { const error = new Error( // eslint-disable-next-line quotes "Failed to execute 'fetch' on 'WorkerGlobalScope': Illegal invocation" ) error.name = 'TypeError' throw error78 unmodified linesmodified:src/helper/css/common.case.test.tsx-1 removed
1-/* eslint-disable quotes */1 /** @jsxImportSource ../../jsx */2 import type {3 Style as StyleComponent,4 css as cssHelper,503 unmodified linesmodified:src/helper/css/common.ts+1 added-1 removed
49 unmodified lines50 }51 52 const cssStringReStr: string = [53 '"(?:(?:\\\\[\\s\\S]|[^"\\\\])*)"', // double quoted string54- // eslint-disable-next-line quotes54+55 "'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'", // single quoted string56 ].join('|')57 const minifyCssRe: RegExp = new RegExp(58 [185 unmodified linesmodified:src/helper/html/index.test.ts+3 added-5 removed
2 unmodified lines3 4 describe('Tagged Template Literals', () => {5 it('Should escape special characters', () => {6 const name = 'John "Johnny" Smith'7- // eslint-disable-next-line quotes7+8 expect(html`<p>I'm ${name}.</p>`.toString()).toBe("<p>I'm John "Johnny" Smith.</p>")9 })10 11 describe('Booleans, Null, and Undefined Are Ignored', () => {22 unmodified lines34 it('Should return Promise<string> when some variables contains Promise<string> in variables', async () => {35 const name = Promise.resolve('John "Johnny" Smith')36 const res = html`<p>I'm ${name}.</p>`37 expect(res).toBeInstanceOf(Promise)38- // eslint-disable-next-line quotes38+39 expect((await res).toString()).toBe("<p>I'm John "Johnny" Smith.</p>")40 })41 42 it('Should return raw value when some variables contains Promise<HtmlEscapedString> in variables', async () => {15 unmodified lines58 },59 ])60 const res = html`<p>I'm ${name}.</p>`61 expect(res).toBeInstanceOf(Promise)62- // eslint-disable-next-line quotes62+63 expect((await res).toString()).toBe("<p>I'm Hono.</p>")64 expect(await resolveCallback(await res, HtmlEscapedCallbackPhase.Stringify, false, {})).toBe(65- // eslint-disable-next-line quotes65 "<p>I'm Hono!.</p>"66 )67 })68 })2 unmodified lines71 describe('raw', () => {72 it('Should be marked as escaped.', () => {73 const name = 'John "Johnny" Smith'74 expect(html`<p>I'm ${raw(name)}.</p>`.toString()).toBe(76- // eslint-disable-next-line quotes75 "<p>I'm John "Johnny" Smith.</p>"76 )77 })78 })modified:src/jsx/dom/css.ts+1 added-2 removed
25 unmodified lines26 for (let i = 0, len = rule.length; i < len; i++) {27 const char = rule[i]28 29 // consume quote30- // eslint-disable-next-line quotes30+31 if (char === "'" || char === '"') {32 const quote = char33 i++34 for (; i < len; i++) {8 unmodified lines43 continue44 }45 46 // comments are removed from the rule in advance47-47 if (char === '{') {48 depth++49 continue50 }194 unmodified linesmodified:src/middleware/basic-auth/index.ts+1 added-1 removed
47 unmodified lines48 * app.use(49 * '/auth/*',50 * basicAuth({51 * username: 'hono',52- * password: 'acoolproject',52+ * password: 'ahotproject',53 * })54 * )55 *56 * app.get('/auth/page', (c) => {72 unmodified linesmodified:src/middleware/bearer-auth/index.ts+1 added-1 removed
58 unmodified lines59 * @example60 * ```ts61 * const app = new Hono()62 *63- * const token = 'honoiscool'63+ * const token = 'honoishot'64 *65 * app.use('/api/*', bearerAuth({ token }))66 *67 * app.get('/api/page', (c) => {92 unmodified linesmodified:src/middleware/body-limit/index.test.ts+3 added-3 removed
18 unmodified lines19 20 describe('Body Limit Middleware', () => {21 let app: Hono22 23- const exampleText = 'hono is so cool' // 15byte24- const exampleText2 = 'hono is so cool and cute' // 24byte23+ const exampleText = 'hono is so hot' // 14byte24+ const exampleText2 = 'hono is so hot and cute' // 23byte25 26 beforeEach(() => {27 app = new Hono()28- app.use('*', bodyLimit({ maxSize: 15 }))28+ app.use('*', bodyLimit({ maxSize: 14 }))29 app.get('/', (c) => c.text('index'))30 app.post('/body-limit-15byte', async (c) => {31 return c.text(await c.req.raw.text())32 })101 unmodified linesmodified:src/middleware/context-storage/index.test.ts+2 added-2 removed
10 unmodified lines11 const app = new Hono<Env>()12 13 app.use(contextStorage())14 app.use(async (c, next) => {15- c.set('message', 'Hono is cool!!')15+ c.set('message', 'Hono is hot!!')16 await next()17 })18 app.get('/', (c) => {19 return c.text(getMessage())4 unmodified lines24 }25 26 it('Should get context', async () => {27 const res = await app.request('/')28- expect(await res.text()).toBe('Hono is cool!!')28+ expect(await res.text()).toBe('Hono is hot!!')29 })30 })modified:src/middleware/context-storage/index.ts+1 added-1 removed
27 unmodified lines28 *29 * app.use(contextStorage())30 *31 * app.use(async (c, next) => {32- * c.set('message', 'Hono is cool!!)32+ * c.set('message', 'Hono is hot!!)33 * await next()34 * })35 *36 * app.get('/', async (c) => { c.text(getMessage()) })19 unmodified linesmodified:src/middleware/etag/index.test.ts+16 added-16 removed
4 unmodified lines5 it('Should return etag header', async () => {6 const app = new Hono()7 app.use('/etag/*', etag())8 app.get('/etag/abc', (c) => {9- return c.text('Hono is cool')9+ return c.text('Hono is hot')10 })11 app.get('/etag/def', (c) => {12- return c.json({ message: 'Hono is cool' })12+ return c.json({ message: 'Hono is hot' })13 })14 let res = await app.request('http://localhost/etag/abc')15 expect(res.headers.get('ETag')).not.toBeFalsy()16- expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')16+ expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')17 18 res = await app.request('http://localhost/etag/def')19 expect(res.headers.get('ETag')).not.toBeFalsy()20- expect(res.headers.get('ETag')).toBe('"4515561204e8269cb4468d5b39288d8f2482dcfe"')20+ expect(res.headers.get('ETag')).toBe('"67340414f1a52c4669a6cec71f0ae04532b29249"')21 })22 23 it('Should return etag header with another algorithm', async () => {24 const app = new Hono()9 unmodified lines34 ),35 })36 )37 app.get('/etag/abc', (c) => {38- return c.text('Hono is cool')38+ return c.text('Hono is hot')39 })40 app.get('/etag/def', (c) => {41- return c.json({ message: 'Hono is cool' })41+ return c.json({ message: 'Hono is hot' })42 })43 let res = await app.request('http://localhost/etag/abc')44 expect(res.headers.get('ETag')).not.toBeFalsy()45 expect(res.headers.get('ETag')).toBe(46- '"ee7e84f92c4f54fec768123ac23003a6eb8437db95bcfbfc35db477af1ccb49e"'46+ '"ed00834279b4fd5dcdc7ab6a5c9774de8afb2de30da2c8e0f17d0952839b5370"'47 )48 49 res = await app.request('http://localhost/etag/def')50 expect(res.headers.get('ETag')).not.toBeFalsy()51 expect(res.headers.get('ETag')).toBe(52- '"6ae7438c67f07b60b2ab069dbce206b00d3528c690840a77e0222d37398a8547"'52+ '"83b61a767db6e22afea68dd645b4d4597a06276c8ce7f895ad865cf4ab154ec4"'53 )54 })55 56 it('Should return etag header - binary', async () => {101 unmodified lines158 it('Should return etag header - weak', async () => {159 const app = new Hono()160 app.use('/etag/*', etag({ weak: true }))161 app.get('/etag/abc', (c) => {162- return c.text('Hono is cool')162+ return c.text('Hono is hot')163 })164 165 const res = await app.request('http://localhost/etag/abc')166 expect(res.headers.get('ETag')).not.toBeFalsy()167- expect(res.headers.get('ETag')).toBe('W/"4e32298b1cb4edc595237405e5b696e105c2399a"')167+ expect(res.headers.get('ETag')).toBe('W/"d104fafdb380655dab607c9bddc4d4982037afa1"')168 })169 170 it('Should handle conditional GETs', async () => {171 const app = new Hono()49 unmodified lines221 it('Should not return duplicate etag header values', async () => {222 const app = new Hono()223 app.use('/etag/*', etag())224 app.use('/etag/*', etag())225- app.get('/etag/abc', (c) => c.text('Hono is cool'))225+ app.get('/etag/abc', (c) => c.text('Hono is hot'))226 227 const res = await app.request('http://localhost/etag/abc')228 expect(res.headers.get('ETag')).not.toBeFalsy()229- expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')229+ expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')230 })231 232 it('Should not override ETag headers from upstream', async () => {233 const app = new Hono()16 unmodified lines250 retainedHeaders: ['x-message-retain', ...RETAINED_304_HEADERS],251 })252 )253 app.get('/etag', (c) => {254- return c.text('Hono is cool', 200, {254+ return c.text('Hono is hot', 200, {255 'cache-control': cacheControl,256 'x-message-retain': message,257 'x-message': message,258 })259 })260 const res = await app.request('/etag', {261 headers: {262- 'If-None-Match': '"4e32298b1cb4edc595237405e5b696e105c2399a"',262+ 'If-None-Match': '"d104fafdb380655dab607c9bddc4d4982037afa1"',263 },264 })265 expect(res.status).toBe(304)266 expect(res.headers.get('ETag')).not.toBeFalsy()267- expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')267+ expect(res.headers.get('ETag')).toBe('"d104fafdb380655dab607c9bddc4d4982037afa1"')268 expect(res.headers.get('Cache-Control')).toBe(cacheControl)269 expect(res.headers.get('x-message-retain')).toBe(message)270 expect(res.headers.get('x-message')).toBeFalsy()271 })15 unmodified lines287 288 it('Should not generate etag', async () => {289 const app = new Hono()290 app.use('/etag/*', etag())291- app.get('/etag/no-digest', (c) => c.text('Hono is cool'))291+ app.get('/etag/no-digest', (c) => c.text('Hono is hot'))292 const res = await app.request('/etag/no-digest')293 expect(res.status).toBe(200)294 expect(res.headers.get('ETag')).toBeNull()295 })2 unmodified linesmodified:src/middleware/etag/index.ts+1 added-1 removed
66 unmodified lines67 * const app = new Hono()68 *69 * app.use('/etag/*', etag())70 * app.get('/etag/abc', (c) => {71- * return c.text('Hono is cool')71+ * return c.text('Hono is hot')72 * })73 * ```74 */75 export const etag = (options?: ETagOptions): MiddlewareHandler => {41 unmodified linesmodified:src/middleware/request-id/index.test.ts+6 added-6 removed
18 unmodified lines19 20 it('Should return custom request id', async () => {21 const res = await app.request('http://localhost/requestId', {22 headers: {23- 'X-Request-Id': 'hono-is-cool',23+ 'X-Request-Id': 'hono-is-hot',24 },25 })26 expect(res).not.toBeNull()27 expect(res.status).toBe(200)28- expect(res.headers.get('X-Request-Id')).toBe('hono-is-cool')29- expect(await res.text()).toBe('hono-is-cool')28+ expect(res.headers.get('X-Request-Id')).toBe('hono-is-hot')29+ expect(await res.text()).toBe('hono-is-hot')30 })31 32 it('Should return random request id without using request header', async () => {33 const res = await app.request('http://localhost/requestId', {101 unmodified lines135 136 it('Should return custom request id', async () => {137 const res = await app.request('http://localhost/requestId', {138 headers: {139- 'Hono-Request-Id': 'hono-is-cool',139+ 'Hono-Request-Id': 'hono-is-hot',140 },141 })142 expect(res).not.toBeNull()143 expect(res.status).toBe(200)144- expect(res.headers.get('Hono-Request-Id')).toBe('hono-is-cool')145- expect(await res.text()).toBe('hono-is-cool')144+ expect(res.headers.get('Hono-Request-Id')).toBe('hono-is-hot')145+ expect(await res.text()).toBe('hono-is-hot')146 })147 148 it('Should not return request id', async () => {149 const res = await app.request('http://localhost/emptyId')6 unmodified linesmodified:src/middleware/secure-headers/index.test.ts+4 added-5 removed
1-/* eslint-disable quotes */1 import { Hono } from '../../hono'2 import { poweredBy } from '../powered-by'3 import { NONCE, secureHeaders } from '.'4 import type { ContentSecurityPolicyOptionHandler } from '.'192 unmodified lines197 it('Remove X-Powered-By', async () => {198 const app = new Hono()199 200 app.get('/test', secureHeaders(), poweredBy(), async (c) => {202- return c.text('Hono is cool')201+ return c.text('Hono is hot')202 })203 204 app.get(205 '/test2',1 unmodified line207 removePoweredBy: false,208 }),209 poweredBy(),210 async (c) => {212- return c.text('Hono is cool')211+ return c.text('Hono is hot')212 }213 )214 215 const res = await app.request('/test')216 const poweredby = res.headers.get('X-Powered-By')217 expect(poweredby).toEqual(null)219- expect(await res.text()).toEqual('Hono is cool')218+ expect(await res.text()).toEqual('Hono is hot')219 220 const res2 = await app.request('/test2')221 const poweredby2 = res2.headers.get('X-Powered-By')222 expect(poweredby2).toEqual('Hono')224- expect(await res2.text()).toEqual('Hono is cool')223+ expect(await res2.text()).toEqual('Hono is hot')224 })225 226 describe.each([227 { cspSettingName: 'contentSecurityPolicy', cspHeaderName: 'Content-Security-Policy' },254 unmodified linesmodified:src/utils/accept.test.ts+1 added-1 removed
45 unmodified lines46 const result = parseAccept(header)47 expect(result[0].params).toEqual({48 a: '1',49 b: '"2"',50- // eslint-disable-next-line quotes50+51 c: "'3'",52 d: '"semi;colon"',53 e: '"nested"quoted""',54 })104 unmodified linesmodified:src/context.ts+1 added-1 removed
573 unmodified lines574 *575 * @example576 * ```ts577 * app.use('*', async (c, next) => {578- * c.set('message', 'Hono is cool!!')578+ * c.set('message', 'Hono is hot!!')579 * await next()580 * })581 * ```582 */283 unmodified lines