Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: honojs/hono
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.1.4
Choose a base ref
...
head repository: honojs/hono
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.1.5
Choose a head ref
  • 4 commits
  • 7 files changed
  • 3 contributors

Commits on Mar 26, 2024

  1. perf: Don't use Arrap.prototype.map if it is not needed return value (

    #2419)
    
    * perf: don't use `.map` if not needed return value
    
    * chore: denoify
    nakasyou authored Mar 26, 2024
    Copy the full SHA
    d340394 View commit details

Commits on Mar 27, 2024

  1. fix(aws-lambda): handle response without body (#2401) (#2413)

    In case of a streaming lambda, the response should still contain metadata
    like status and content type, even if no body is given.
    This could be for example a redirect response.
    KnisterPeter authored Mar 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f590d0f View commit details
  2. fix(validator): await cached contents (#2430)

    * fix(validator): `await` cached contents
    
    * denoify
    yusukebe authored Mar 27, 2024
    Copy the full SHA
    1d30cec View commit details
  3. v4.1.5

    yusukebe committed Mar 27, 2024
    Copy the full SHA
    b8855e8 View commit details
Showing with 23 additions and 15 deletions.
  1. +3 −3 deno_dist/hono-base.ts
  2. +2 −2 deno_dist/validator/validator.ts
  3. +1 −1 package.json
  4. +6 −4 src/adapter/aws-lambda/handler.ts
  5. +3 −3 src/hono-base.ts
  6. +6 −0 src/validator/validator.test.ts
  7. +2 −2 src/validator/validator.ts
6 changes: 3 additions & 3 deletions deno_dist/hono-base.ts
Original file line number Diff line number Diff line change
@@ -111,14 +111,14 @@ class Hono<

// Implementation of app.get(...handlers[]) or app.get(path, ...handlers[])
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]
allMethods.map((method) => {
allMethods.forEach((method) => {
this[method] = (args1: string | H, ...args: H[]) => {
if (typeof args1 === 'string') {
this.#path = args1
} else {
this.addRoute(method, this.#path, args1)
}
args.map((handler) => {
args.forEach((handler) => {
if (typeof handler !== 'string') {
this.addRoute(method, this.#path, handler)
}
@@ -154,7 +154,7 @@ class Hono<
this.#path = '*'
handlers.unshift(arg1)
}
handlers.map((handler) => {
handlers.forEach((handler) => {
this.addRoute(METHOD_NAME_ALL, this.#path, handler)
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4 changes: 2 additions & 2 deletions deno_dist/validator/validator.ts
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ export const validator = <
}

if (c.req.bodyCache.json) {
value = c.req.bodyCache.json
value = await c.req.bodyCache.json
break
}

@@ -99,7 +99,7 @@ export const validator = <
}

if (c.req.bodyCache.formData) {
value = c.req.bodyCache.formData
value = await c.req.bodyCache.formData
break
}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hono",
"version": "4.1.4",
"version": "4.1.5",
"description": "Ultrafast web framework for the Edges",
"main": "dist/cjs/index.js",
"type": "module",
10 changes: 6 additions & 4 deletions src/adapter/aws-lambda/handler.ts
Original file line number Diff line number Diff line change
@@ -126,11 +126,13 @@ export const streamHandle = <
headers: Object.fromEntries(res.headers.entries()),
}

// Update response stream
responseStream = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata)

if (res.body) {
await streamToNodeStream(
res.body.getReader(),
awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata)
)
await streamToNodeStream(res.body.getReader(), responseStream)
} else {
responseStream.write('')
}
} catch (error) {
console.error('Error processing request:', error)
6 changes: 3 additions & 3 deletions src/hono-base.ts
Original file line number Diff line number Diff line change
@@ -111,14 +111,14 @@ class Hono<

// Implementation of app.get(...handlers[]) or app.get(path, ...handlers[])
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]
allMethods.map((method) => {
allMethods.forEach((method) => {
this[method] = (args1: string | H, ...args: H[]) => {
if (typeof args1 === 'string') {
this.#path = args1
} else {
this.addRoute(method, this.#path, args1)
}
args.map((handler) => {
args.forEach((handler) => {
if (typeof handler !== 'string') {
this.addRoute(method, this.#path, handler)
}
@@ -154,7 +154,7 @@ class Hono<
this.#path = '*'
handlers.unshift(arg1)
}
handlers.map((handler) => {
handlers.forEach((handler) => {
this.addRoute(METHOD_NAME_ALL, this.#path, handler)
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6 changes: 6 additions & 0 deletions src/validator/validator.test.ts
Original file line number Diff line number Diff line change
@@ -186,6 +186,9 @@ describe('Cached contents', () => {
await next()
},
validator('json', (value) => {
if (value instanceof Promise) {
throw new Error('Value is Promise')
}
return value
}),
async (c) => {
@@ -224,6 +227,9 @@ describe('Cached contents', () => {
await next()
},
validator('form', (value) => {
if (value instanceof Promise) {
throw new Error('Value is Promise')
}
return value
}),
async (c) => {
4 changes: 2 additions & 2 deletions src/validator/validator.ts
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ export const validator = <
}

if (c.req.bodyCache.json) {
value = c.req.bodyCache.json
value = await c.req.bodyCache.json
break
}

@@ -99,7 +99,7 @@ export const validator = <
}

if (c.req.bodyCache.formData) {
value = c.req.bodyCache.formData
value = await c.req.bodyCache.formData
break
}