Skip to content
Myr

chore: add `format` script (#1334)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* add format * yarn format:fix * fix linter

authored by watany · committed by GitHub · parent 4a990cf · Browse files · 11 files+93 added−75 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+93 added−75 removed

  • tests:+6 added−5 removed
  • other:+87 added−70 removed

11 files+93 added−75 removed

modified:.github/workflows/ci.yml+1 added
modified:runtime_tests/lambda-edge/index.test.ts+1 added-1 removed
1088 unmodified lines
1089 ],1090 }10911092 let called = false1093 await handler(event, {}, (_err, result) => {1093 await handler(event, {}, (_, result) => {1094 called = true1095 })10961097 expect(called).toBe(true)
2 unmodified lines
modified:src/adapter/aws-lambda/custom-context.ts+64 added-64 removed
modified:src/adapter/aws-lambda/index.ts-1 removed
1// @denoify-ignore2export { handle } from './handler'3export type { ApiGatewayRequestContext, LambdaFunctionUrlRequestContext } from './custom-context'4
modified:src/adapter/lambda-edge/handler.ts+2 added-1 removed
143 unmodified lines
144 v.forEach((header) => headers.set(k, header.value))145 })146147 const requestBody = event.Records[0].cf.request.body148 const body =148 const body = requestBody?.encoding === 'base64' && requestBody?.data149 requestBody?.encoding === 'base64' && requestBody?.data150 ? Buffer.from(requestBody.data, 'base64')151 : requestBody?.data152153 return new Request(url, {
11 unmodified lines
modified:src/adapter/lambda-edge/index.ts+7 added-1 removed
1// @denoify-ignore2export { handle } from './handler'3export type { Callback, CloudFrontConfig, CloudFrontRequest, CloudFrontResponse, CloudFrontEdgeEvent } from './handler'3export type {4 Callback,5 CloudFrontConfig,6 CloudFrontRequest,7 CloudFrontResponse,8 CloudFrontEdgeEvent,9} from './handler'
modified:src/client/client.ts+4 added-1 removed
105 unmodified lines
106 }107}108109// eslint-disable-next-line @typescript-eslint/no-explicit-any110export const hc = <T extends Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions) =>110export const hc = <T extends Hono<any, any, any>>(111 baseUrl: string,112 options?: ClientRequestOptions113) =>114 createProxy(async (opts) => {115 const parts = [...opts.path]116117 let method = ''
17 unmodified lines
modified:src/middleware/compress/index.test.ts+2 added-3 removed
1import { Hono } from '../../hono'2import { compress } from '.'34describe('Parse Compress Middleware', () => {55 const app = new Hono()67 app.use('*', compress())8 app.get('/hello', async (ctx) => {
9 unmodified lines
18 expect(res).not.toBeNull()19 expect(res.status).toBe(200)20 expect(res.headers.get('Content-Encoding')).toEqual('gzip')21 })23 2223 it('deflate', async () => {24 const req = new Request('http://localhost/hello', {25 method: 'GET',26 headers: new Headers({ 'Accept-Encoding': 'deflate' }),
2 unmodified lines
29 expect(res).not.toBeNull()30 expect(res.status).toBe(200)31 expect(res.headers.get('Content-Encoding')).toEqual('deflate')32 })34 3334 it('gzip or deflate', async () => {35 const req = new Request('http://localhost/hello', {36 method: 'GET',37 headers: new Headers({ 'Accept-Encoding': 'gzip, deflate' }),
17 unmodified lines
modified:src/middleware/etag/index.test.ts+3 added-1 removed
134 unmodified lines
135 expect(res.headers.get('ETag')).toBe('"4e32298b1cb4edc595237405e5b696e105c2399a"')136 })137138 it('Should not override ETag headers from upstream', async () => {139 app.get('/etag/predefined', (c) => c.text('This response has an ETag', 200, { ETag: '"f-0194-d"'}))139 app.get('/etag/predefined', (c) =>140 c.text('This response has an ETag', 200, { ETag: '"f-0194-d"' })141 )142143 const res = await app.request('http://localhost/etag/predefined')144 expect(res.headers.get('ETag')).toBe('"f-0194-d"')145 })
1 unmodified line
modified:src/middleware/etag/index.ts+7 added-2 removed
1import type { MiddlewareHandler } from '../../types'2import { sha1 } from '../../utils/crypto'34type ETagOptions = {5 retainedHeaders?: string[],5 retainedHeaders?: string[]6 weak?: boolean7}89/**
2 unmodified lines
12 * > would have been sent in an equivalent 200 OK response: Cache-Control,13 * > Content-Location, Date, ETag, Expires, and Vary.14 */15const RETAINED_304_HEADERS = [16 'cache-control', 'content-location', 'date', 'etag', 'expires', 'vary'16 'cache-control',17 'content-location',18 'date',19 'etag',20 'expires',21 'vary',22]2324function etagMatches(etag: string, ifNoneMatch: string | null) {25 return ifNoneMatch != null && ifNoneMatch.split(/,\s*/).indexOf(etag) > -1
38 unmodified lines
modified:package.json+2 added
20 unmodified lines
21 "test:lambda-edge": "env NAME=Node jest --config ./runtime_tests/lambda-edge/jest.config.js",22 "test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",23 "lint": "eslint --ext js,ts src runtime_tests .eslintrc.cjs",24 "lint:fix": "eslint --ext js,ts src runtime_tests .eslintrc.cjs --fix",25 "format": "prettier --check 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",26 "format:fix": "prettier --write 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",27 "denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'",28 "copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",29 "build": "rimraf dist && tsx ./build.ts && yarn copy:package.cjs.json",30 "postbuild": "publint",
384 unmodified lines