From 5723cc08c505ab817166cf79d2dee56bd15d8c19 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Fri, 17 Mar 2023 17:11:24 +0900 Subject: [PATCH] feat(typebox-validator): support Hono v3.1.0 (#65) * feat(typebox-validator): support Hono v3.1.0 * add changeset --- .changeset/slimy-shrimps-dance.md | 5 +++++ packages/typebox-validator/package.json | 8 ++++---- packages/typebox-validator/src/index.ts | 6 +++++- packages/typebox-validator/test/index.test.ts | 2 +- yarn.lock | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .changeset/slimy-shrimps-dance.md diff --git a/.changeset/slimy-shrimps-dance.md b/.changeset/slimy-shrimps-dance.md new file mode 100644 index 00000000..7f6dd575 --- /dev/null +++ b/.changeset/slimy-shrimps-dance.md @@ -0,0 +1,5 @@ +--- +'@hono/typebox-validator': minor +--- + +feat: Support Hono v3.1.0 diff --git a/packages/typebox-validator/package.json b/packages/typebox-validator/package.json index 3cb24403..aa47e166 100644 --- a/packages/typebox-validator/package.json +++ b/packages/typebox-validator/package.json @@ -28,11 +28,11 @@ }, "homepage": "https://github.com/honojs/middleware", "peerDependencies": { - "hono": "3.*", - "@sinclair/typebox": "^0.25.24" + "@sinclair/typebox": "^0.25.24", + "hono": "3.*" }, "devDependencies": { - "hono": "^3.0.0", - "@sinclair/typebox": "^0.25.24" + "@sinclair/typebox": "^0.25.24", + "hono": "^3.1.0" } } diff --git a/packages/typebox-validator/src/index.ts b/packages/typebox-validator/src/index.ts index fc7fa6c5..9b330a76 100644 --- a/packages/typebox-validator/src/index.ts +++ b/packages/typebox-validator/src/index.ts @@ -63,7 +63,11 @@ export function tbValidator< target: Target, schema: T, hook?: Hook> -): MiddlewareHandler }> { +): MiddlewareHandler< + E, + P, + { in: { [K in Target]: Static }; out: { [K in Target]: Static } } +> { // Compile the provided schema once rather than per validation. This could be optimized further using a shared schema // compilation pool similar to the Fastify implementation. const compiled = TypeCompiler.Compile(schema) diff --git a/packages/typebox-validator/test/index.test.ts b/packages/typebox-validator/test/index.test.ts index 9ad3721d..6f971079 100644 --- a/packages/typebox-validator/test/index.test.ts +++ b/packages/typebox-validator/test/index.test.ts @@ -33,7 +33,7 @@ describe('Basic', () => { } } output: { - success: boolean + success: true message: string } } diff --git a/yarn.lock b/yarn.lock index ba49dfb5..f6a6033e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5232,7 +5232,7 @@ hono@^3.0.2: resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.2.tgz#807a1b0514c6563917d8c278e6da7101bdac1d19" integrity sha512-jhb0eCiUTOzbOXZyXQCOk1gf3MKjV4ZXY3PRT6lzma0XPsnnHuDOHYF7RCMHYe7jhl4Y0IAzrmWXneXhOMHypA== -hono@^3.1.0: +hono@^3.0.3, hono@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/hono/-/hono-3.1.0.tgz#4b29bcaddc489015b99d0a89b68133ccf72b2cf1" integrity sha512-5hVyzp3mrAjxRwy6Uj7su0pIISGTKVX2tE4YiYO81V3w1KoYZEmz3g6X6P9nRLQmaABDWXmnL9GqEzBhTAPeog==