fix(zod-validator): bump up Hono to v3.0.0-rc.9 (#27)

pull/28/head
Yusuke Wada 2023-02-01 06:53:53 +09:00 committed by GitHub
parent e4a995f7e2
commit e45805f230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 26 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/zod-validator': patch
---
bump up Hono version to v3.0.0-rc.9

View File

@ -28,14 +28,11 @@
},
"homepage": "https://github.com/honojs/middleware",
"peerDependencies": {
"hono": "^3.0.0-rc.3",
"hono": "^3.0.0-rc.9",
"zod": "^3.19.1"
},
"devDependencies": {
"hono": "3.0.0-rc.3",
"hono": "3.0.0-rc.9",
"zod": "3.19.1"
},
"dependencies": {
"hono": "3.0.0-rc.7"
}
}

View File

@ -18,7 +18,7 @@ export const zValidator = <
type: Type,
schema: T,
hook?: Hook<z.infer<T>>
): MiddlewareHandler<E, P, { type: Type; data: z.infer<T> }> =>
): MiddlewareHandler<E, P, { [K in Type]: z.infer<T> }> =>
validator(type, (value, c) => {
const result = schema.safeParse(value)

View File

@ -3,6 +3,9 @@ import type { Equal, Expect } from 'hono/utils/types'
import { z } from 'zod'
import { zValidator } from '../src'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never
describe('Basic', () => {
const app = new Hono()
@ -11,20 +14,18 @@ describe('Basic', () => {
age: z.number(),
})
const route = app
.post('/author', zValidator('json', schema), (c) => {
const data = c.req.valid()
return c.jsonT({
success: true,
message: `${data.name} is ${data.age}`,
})
const route = app.post('/author', zValidator('json', schema), (c) => {
const data = c.req.valid()
return c.jsonT({
success: true,
message: `${data.name} is ${data.age}`,
})
.build()
})
type Actual = typeof route
type Actual = ExtractSchema<typeof route>
type Expected = {
post: {
'/author': {
'/author': {
$post: {
input: {
json: {
name: string
@ -32,17 +33,15 @@ describe('Basic', () => {
}
}
output: {
json: {
success: boolean
message: string
}
success: boolean
message: string
}
}
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type verify = Expect<Equal<Actual, Expected>>
type verify = Expect<Equal<Expected, Actual>>
it('Should return 200 response', async () => {
const req = new Request('http://localhost/author', {

View File

@ -2785,10 +2785,10 @@ hono@3.0.0-rc.4:
resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.0-rc.4.tgz#7bfe8c89d4b004ff90d587c8ba45279a175fbce7"
integrity sha512-76R3mb8kPeuD9TOmQ1WZi59w4QbpaUOlyX3wC7zQpt7IM7iFVBTxj2fpv++6ROPtd5iUBMCrmH/65ZrNXYYgmg==
hono@3.0.0-rc.7:
version "3.0.0-rc.7"
resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.0-rc.7.tgz#c6a5c44ce7fad1e187f47e1d7828a20fad2b20b2"
integrity sha512-ZiAz4XnIDgRFw8ZRwvxv8EfArEoCOdxkz1rDE2N6TOrYi7mf7DGIbIjgj/T1CwXlbV9VulKU17IqEZg0asqkTQ==
hono@3.0.0-rc.9:
version "3.0.0-rc.9"
resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.0-rc.9.tgz#6077bc67fce850dca99cd58452bda21ff8984da8"
integrity sha512-gW/I51Uay6RhrDhtRN/3WTg7ALT3VRdk0NZBdGpkEOgF+TrzFwmWHDbzHUPa9MffiXSlrkFtMmJVvdKO3Iab8Q==
hono@^2.3.0:
version "2.6.2"