Compare commits

...

93 Commits

Author SHA1 Message Date
github-actions[bot] 5cba9a4819
Version Packages (#1233)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-16 11:29:29 +09:00
github-actions[bot] acff470c7f
Version Packages (#1232)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-16 11:24:22 +09:00
Jonathan Haines 9235709060
refactor: composite build (#1230)
* refactor: composite build

* chore(ua-blocker): move demo.ts out of src
2025-06-16 11:23:47 +09:00
github-actions[bot] 40f916f944
chore(ua-blocker): update robots.json from upstream (#1229)
* chore(ua-blocker): update robots.json from upstream

* add changeset

* format

---------

Co-authored-by: yusukebe <10682+yusukebe@users.noreply.github.com>
Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2025-06-16 11:00:08 +09:00
Max Gerber a2409d2314
chore: Prettier should operate on all files (#1222)
* chore: Prettier should operate on all files

* Update package.json

Co-authored-by: Jonathan Haines <jonno.haines@gmail.com>

---------

Co-authored-by: Jonathan Haines <jonno.haines@gmail.com>
2025-06-15 09:08:01 +09:00
github-actions[bot] cf3c17e3d1
Version Packages (#1228)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-14 06:08:40 +09:00
Yusuke Wada 7c6a860814
chore: update the lockfile (#1226) 2025-06-14 06:05:24 +09:00
Colin Ozanne be73703184
feat: introduce UA Blocker Middleware (#1181)
* feat: create AI bot blocker middleware

* chore: add changeset

* fix: uppercase function called too late

* chore: don't version-control robots.json

* chore: track `robots.json`

* ci: add `@hono/ai-robots-txt` workflow script

* fix: change initial version

* feat: add automatic `robots.json` sync from upstream

* feat!: change package name and architecture

* refactor(ua-blocker): prebuild compiled regex (#1)

* fix: add json data files to tsconfig

* chore: rename workflow files

* fix: test if string _contains_ "Yes"

It might be a markdown link, so not the exact string, but "[Yes](<link>)"

* fix: tests reflect the fixed "Yes" check

* feat: move generator back to prebuild

generated regex should use the version-controled robots.json, not
directly the upstream file

* chore: add .zed

* chore: remove unused files

* fix: properly setup workspace before running scripts

* chore: remove `prebuild` script from `build`, `typecheck`, and `test`

* chore: run `getrobotstxt` and `prebuild`

* fix: export `RegExp`s, not `string[]`s

* chore: mention RegExp and uppercase matching in docs

* fix: adapt tests to regex exports

* chore: add tests for direct regex passing

* chore: format code

---------

Co-authored-by: Jonathan Haines <jonno.haines@gmail.com>
2025-06-14 06:00:42 +09:00
github-actions[bot] 2f57dd5ebb
Version Packages (#1225)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-14 05:55:25 +09:00
Yusuke Wada bb56b3176e
chore: update the lockfile (#1224) 2025-06-14 05:51:27 +09:00
Max Gerber ede1aaff4f
feat: Stytch Authentication middleware (#1186)
* feat: Stytch Authentication middlewares

* Add changeset

* Better README

* Refresh yarn.lock

* fix: Remove unused dev deps, linter

* README and light renaming

* Remove ci-stytch-auth workflow

* rerun prettier

* add troubleshooting to readme
2025-06-14 05:48:00 +09:00
Jonathan Haines 44b1c24b95
chore(zod-validator): run prettier to fix CI (#1221)
* chore(zod-validator): run prettier to fix CI

* ci: fix changed packages
2025-06-13 16:18:23 +09:00
Jonathan Haines b73b7aed29
chore: update yarn to v4.9.2 (#1219) 2025-06-13 05:21:52 +09:00
Jonathan Haines a7ee664c98
ci: what changed (#1212) 2025-06-11 19:15:16 +09:00
github-actions[bot] 86a4ca460d
Version Packages (#1211)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-09 19:16:09 +09:00
Jonathan Haines 0758fd0af1
refactor(auth-js): enable isolated declarations (#1210) 2025-06-09 19:11:03 +09:00
github-actions[bot] d4cc24f754
Version Packages (#1206)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-09 19:05:17 +09:00
Jonathan Haines c880649458
refactor: enable isolated declarations (#1209) 2025-06-09 19:00:20 +09:00
Jonathan Haines 3c1ecb0ce9
refactor(otel): enable isolated declarations (#1203)
* refactor(otel): enable isolated declarations

* refactor: remove extra type arguments
2025-06-09 18:58:01 +09:00
Jonathan Haines b8802e01b7
refactor(swagger-ui): enable isolated declarations (#1208) 2025-06-09 18:52:25 +09:00
Jonathan Haines 0bda87e4ee
refactor(swagger-editor): enable isolated declarations (#1207) 2025-06-09 18:49:27 +09:00
Jonathan Haines 1cdfdbd292
refactor(prometheus): enable isolated declarations (#1204) 2025-06-09 18:47:35 +09:00
Jonathan Haines aaf90c39e6
refactor(oidc-auth): enable isolated declarations (#1202) 2025-06-09 18:35:28 +09:00
Jonathan Haines 641fd4c3de
refactor(oauth-providers): enable isolated declarations (#1201) 2025-06-09 18:33:23 +09:00
Jonathan Haines f0475c7324
refactor(sentry): enable isolated declarations (#1205) 2025-06-09 18:31:52 +09:00
Jonathan Haines 8303d979f1
refactor(node-ws): enable isolated declarations (#1200) 2025-06-09 18:23:05 +09:00
Jonathan Haines 50aa61d9c2
refactor(medley-router): enable isolated declarations (#1199) 2025-06-09 18:22:23 +09:00
Jonathan Haines e1eae2078f
refactor(hello): enable isolated declarations (#1198) 2025-06-09 18:17:27 +09:00
Jonathan Haines ab390305fb
refactor(graphql-server): enable isolated declarations (#1197) 2025-06-09 18:16:01 +09:00
Jonathan Haines 3a9920a258
refactor(esbuild-transpiler): enable isolated declarations (#1196) 2025-06-09 18:14:46 +09:00
Jonathan Haines b6f3bc674b
refactor(cloudflare-access): enable isolated declarations (#1195) 2025-06-09 18:12:04 +09:00
Jonathan Haines 683455895d
refactor(clerk-auth): enable isolated declarations (#1194) 2025-06-09 18:11:11 +09:00
Jonathan Haines 1adca4c918
refactor(bun-transpiler): enable isolated declarations (#1193) 2025-06-09 18:10:30 +09:00
github-actions[bot] 471cf0580d
Version Packages (#1192)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-08 11:34:45 +09:00
Jocelyn Boullier a70d91950f
feat(otel): record uncaught expections (#1191) 2025-06-08 11:31:28 +09:00
github-actions[bot] d05b6158ec
Version Packages (#1189)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-02 21:10:02 +09:00
Shotaro Nakamura 69a0a586f5
fix(node-ws): use defineWebSocket helper (#1187)
* fix: use buffering to fix #1129

* chore: changeset

* chore: fmt

* feat(node-ws): use defineWebSocket helper

* changeset
2025-06-02 21:06:25 +09:00
Jonathan Haines 3c70dcd6ae
chore: update hono (#1185) 2025-06-02 05:06:04 +09:00
github-actions[bot] 858c6b4fc3
Version Packages (#1184)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-01 11:25:25 +09:00
Shotaro Nakamura ccc49dd508
fix(node-ws): use buffering to fix #1129 (#1183)
* fix: use buffering to fix #1129

* chore: changeset

* chore: fmt
2025-06-01 11:12:23 +09:00
github-actions[bot] 2fccb8b764
Version Packages (#1182)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-30 11:16:13 +09:00
Yusuke Wada 5c3f61f889
feat(zod-validator): update peerDependency to Zod `^3.25.0` and fix the types (#1180)
* feat(zod-validator): update peerDependency to Zod ^3.25.0 and fix type compatibility

* add changeset
2025-05-30 10:40:47 +09:00
Yusuke Wada c97fcf08b2
chore: add Claude Code local files to gitignore (#1179)
Add CLAUDE.local.md and settings.local.json to gitignore to prevent
committing Claude Code local configuration files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-05-29 19:59:38 +09:00
github-actions[bot] 9afa292ca5
Version Packages (#1176)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-27 17:55:25 +09:00
Yusuke Wada a62b59f450
feat(zod-validator): support Zod v4 (#1173)
* feat(zod-validator): support Zod v4

* changeset

* oops. using `any`

* remove the not used value

* [wip] support both v3 and v4

* update

* avoid the type error on build

* remove unnecessary `unknown`

* fixed type and add test

* avoid the type error

* rename the test

* don't use `schema instanceof ZodObject`

* update README

* use released `3.25.6`

* changeset

* use `zod` instead of `zod/v3`

* don't update the peerDependencies

* use both v3 and v4 types if Zod has v4

* fix ZodError

* fixed

* update lock file

* update README

* remove unnecessary cast
2025-05-27 17:47:54 +09:00
Jonathan Haines deeeac9e1c
lint: array-type (#1165)
* lint: array-type

* format

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2025-05-19 16:00:53 +09:00
github-actions[bot] 52a1d46cd2
Version Packages (#1172)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-17 11:20:38 +09:00
Danial Hanif 7585969171
fix(auth-js): use HonoRequest.blob() instead of HonoRequest.raw.body() (#1170)
* fix(auth-js): use HonoRequest.blob() instead of HonoRequest.raw.body()

* lint fix and format fix

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2025-05-17 11:17:28 +09:00
Jonathan Haines 7a45d5749d
ci(oauth-providers): set publish config access to public (#1168) 2025-05-16 09:38:35 +09:00
github-actions[bot] 8fafbc1d4d
Version Packages (#1167)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-16 07:42:31 +09:00
Jonathan Haines cf48336cbd
feat(oauth-providers): Add MSEntra OAuth Provider (#1163)
Co-authored-by: Tim Barley <barleyco@gmail.com>
2025-05-16 07:38:53 +09:00
github-actions[bot] 2c917b33a4
Version Packages (#1166)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-15 23:03:13 +09:00
Jonathan Haines 1ca88da019
fix(release): publish tags (#1161) 2025-05-15 22:59:54 +09:00
Jonathan Haines 74d0fe0cb4
feature(eslint-config): add types (#1162)
fixes #1157
2025-05-15 22:55:48 +09:00
Jonathan Haines d29f2cbdc6
test(bun-compress): fix vitest config (#1164)
* test(bun-compress): fix vitest config

* ci(bun-compress): add workflow
2025-05-15 22:41:48 +09:00
github-actions[bot] e63499755a
Version Packages (#1158)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-13 07:26:50 +09:00
Nicholas Dobie 7717755dd3
feat(bun-compress): Created a compress middleware that supports Bun (#1153)
* feat(bun-compress): Created a compress middlware that supports Bun

* fix(bun-compress): spelling mistake in readme

* fix(bun-compress): package description

* fixed package.json
2025-05-13 07:15:11 +09:00
github-actions[bot] 026e1deac3
Version Packages (#1156)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-12 17:59:40 +09:00
Thomas Orlowski 7d3aa32e79
feat(graphql-server): upgrade GraphiQL (#1155) 2025-05-12 17:56:13 +09:00
github-actions[bot] 20d3fd1fe5
Version Packages (#1152)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-08 08:10:40 +09:00
Nicholas Dobie 414f0a6c95
feat(otel): Added support for W3C Trace Context format (#1151)
* feat(otel): Added support for W3C Trace Context format

* removed unneeded HonoRequest
2025-05-08 07:20:02 +09:00
Shotaro Nakamura 0debb59474
ci: add codestyle ci (#1149) 2025-05-02 16:51:42 +09:00
github-actions[bot] bed23c62f5
Version Packages (#1147)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-29 18:35:32 +09:00
Shotaro Nakamura b8453438b6
fix(node-ws): enhance WebSocket connection handling with CORS support (#1146)
* fix(node-ws): make adapter uncrashable

* add changeset

* unnessesary diff

* fix(node-ws): enhance WebSocket connection handling with CORS support and connection symbols

* fix commentout

* remove unnecessary changese

* update changeset
2025-04-29 18:31:54 +09:00
github-actions[bot] 0dc8b719b4
Version Packages (#1145)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-28 15:21:28 +09:00
Andrei 01cd896e9b
fix(arktype-validator): Don't return restricted fields in error responses (#1137)
* fix(arktype-validator): add failing test for cookie header

* fix(arktype-validator): add restricted fields that are not returned in the "data" field of the error

* chore: add changeset
2025-04-28 15:17:34 +09:00
github-actions[bot] 928f8cd5b8
Version Packages (#1144)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-27 20:38:32 +09:00
Shotaro Nakamura 1765a9a3aa
fix(node-ws): make adapter uncrashable (#1141)
* fix(node-ws): make adapter uncrashable

* add changeset

* unnessesary diff

* update yarn.lock

* make changeset patch
2025-04-27 20:34:43 +09:00
github-actions[bot] 247f7705b3
Version Packages (#1143)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-27 20:30:24 +09:00
Yusuke Wada 8ed99d9d79
feat(zod-validator): add `validationFunction` option (#1140)
Co-authored-by: migawka <migawka@amadeustech.dev>
2025-04-27 20:12:13 +09:00
Yusuke Wada b9fa57530a
chore: format codes (#1142) 2025-04-27 19:28:24 +09:00
github-actions[bot] a756d2235b
Version Packages (#1139)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-26 13:12:27 +09:00
Leia 237bff1b82
fix(node-ws):missing code and reason on CloseEvent (#1138)
fixes #1012
2025-04-26 13:09:26 +09:00
github-actions[bot] abb260632f
Version Packages (#1128)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-18 07:34:31 +09:00
Daniel Tao 63a9dff2b9
chore(zod-openapi): lock zod-to-openapi to `^7.3.0` to fix `z.custom` (#1127)
* chore(zod-openapi): lock zod-to-openapi to `^7.3.0` to fix schemas using `z.custom`

* add changeset
2025-04-18 07:30:36 +09:00
github-actions[bot] 6c36f525f9
Version Packages (#1123)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-11 16:23:32 +09:00
Yusuke Wada 944f1989f5
fix(react-renderer): tweak dynamic importing `renderToReadableStream` (#1122)
* fix(react-renderer): tweak dynamic importing `renderToReadableStream`

* changeset
2025-04-11 16:19:43 +09:00
github-actions[bot] a1fcb554ef
Version Packages (#1121)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-11 07:46:10 +09:00
Yusuke Wada 684ae9a21d
feat(react-renderer): use React v19 and specify `react-dom/server.edge` for `renderToReadableStream` (#1119)
* feat(react-renderer): use React v19 and specify `react-dom/server.edge` for `renderToReadableStream`

* changeset
2025-04-11 07:43:03 +09:00
github-actions[bot] ca3cada076
Version Packages (#1118)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-10 17:47:54 +09:00
Milo Hansen 362b6701a6
fix(otel): Use `req.routePath` when tagging spans (#1113)
* use routePath

Replace indexing into the matchedRoutes with a direct reference to routePath

* Update package.json

Bump version

* set span name and attributes after the request is handled

* revert version bump

* changeset

* add test to ensure subapps set the correct span name

---------

Co-authored-by: Milo Hansen <milo.hansen@avanade.com>
2025-04-10 17:40:54 +09:00
Jonathan Haines bebdfa2a88
ci(release): yarn config set npmAuthToken (#1117) 2025-04-09 19:25:08 +09:00
chimame 26d0efb036
chore(conform-validator): Change conform valibot adapter to official library (#1114) 2025-04-09 19:08:21 +09:00
Jonathan Haines 73c899bc81
ci(release): restore build during release (#1116) 2025-04-09 18:59:58 +09:00
github-actions[bot] 99e7bf2e64
Version Packages (#1115)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-09 18:40:50 +09:00
Jonathan Haines ad4622a853
fix(zod-openapi): republish without workspace reference (#1111)
fixes #1109
2025-04-09 18:37:30 +09:00
github-actions[bot] 542391f8db
Version Packages (#1108)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 19:34:59 +09:00
Jonathan Haines 1fd8ebf9b6
feat(eslint-config): enable linting with type information (#1098) 2025-04-07 19:31:09 +09:00
github-actions[bot] 9f3027a4a0
Version Packages (#1107)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-07 18:46:24 +09:00
Yusuke Wada 448a8fc687
fix(zod-openapi): infer Env correctly if the middleware is `[]` (#1106)
* fix(zod-openapi): infer Env correctly if the middleware is `[]`

* add changeset
2025-04-07 18:41:04 +09:00
github-actions[bot] f349fba499
Version Packages (#1101)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-03 23:23:22 +09:00
liquidleif 091b182a6a
fix(oauth-providers): Update twitter authorization url (#1099)
Closes #1100

* Update twitter authorization url

The twitter authorization URL is outdated.

* add a changeset
2025-04-03 23:18:24 +09:00
Jonathan Haines e8512f0ee9
build: typescript project references (#1077)
* build: typescript project references

* chore: remove duplicate keys
2025-04-02 18:28:02 +09:00
336 changed files with 10930 additions and 4230 deletions

View File

@ -1,31 +0,0 @@
name: ci-ajv-validator
on:
push:
branches: [main]
paths:
- 'packages/ajv-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/ajv-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/ajv-validator
- run: yarn workspace @hono/ajv-validator build
- run: yarn workspace @hono/ajv-validator publint
- run: yarn eslint packages/ajv-validator
- run: yarn test --coverage --project @hono/ajv-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: ajv-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-arktype-validator
on:
push:
branches: [main]
paths:
- 'packages/arktype-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/arktype-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/arktype-validator
- run: yarn workspace @hono/arktype-validator build
- run: yarn workspace @hono/arktype-validator publint
- run: yarn eslint packages/arktype-validator
- run: yarn test --coverage --project @hono/arktype-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: arktype-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-auth-js
on:
push:
branches: [main]
paths:
- 'packages/auth-js/**'
pull_request:
branches: ['*']
paths:
- 'packages/auth-js/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/auth-js
- run: yarn workspace @hono/auth-js build
- run: yarn workspace @hono/auth-js publint
- run: yarn eslint packages/auth-js
- run: yarn test --coverage --project @hono/auth-js
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: auth-js
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -20,7 +20,9 @@ jobs:
- run: yarn workspaces focus hono-middleware @hono/bun-transpiler
- run: yarn workspace @hono/bun-transpiler build
- run: yarn workspace @hono/bun-transpiler publint
- run: yarn workspace @hono/bun-transpiler typecheck
- run: yarn eslint packages/bun-transpiler
- run: yarn prettier --check . !packages packages/bun-transpiler
- run: yarn workspace @hono/bun-transpiler test --coverage --coverage-reporter lcov
- uses: codecov/codecov-action@v5
with:

View File

@ -1,31 +0,0 @@
name: ci-casbin
on:
push:
branches: [main]
paths:
- 'packages/casbin/**'
pull_request:
branches: ['*']
paths:
- 'packages/casbin/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/casbin
- run: yarn workspace @hono/casbin build
- run: yarn workspace @hono/casbin publint
- run: yarn eslint packages/casbin
- run: yarn test --coverage --project @hono/casbin
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: casbin
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-class-validator
on:
push:
branches: [main]
paths:
- 'packages/class-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/class-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/class-validator
- run: yarn workspace @hono/class-validator build
- run: yarn workspace @hono/class-validator publint
- run: yarn eslint packages/class-validator
- run: yarn test --coverage --project @hono/class-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: class-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-clerk-auth
on:
push:
branches: [main]
paths:
- 'packages/clerk-auth/**'
pull_request:
branches: ['*']
paths:
- 'packages/clerk-auth/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/clerk-auth
- run: yarn workspace @hono/clerk-auth build
- run: yarn workspace @hono/clerk-auth publint
- run: yarn eslint packages/clerk-auth
- run: yarn test --coverage --project @hono/clerk-auth
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: clerk-auth
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-cloudflare-access
on:
push:
branches: [main]
paths:
- 'packages/cloudflare-access/**'
pull_request:
branches: ['*']
paths:
- 'packages/cloudflare-access/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/cloudflare-access
- run: yarn workspace @hono/cloudflare-access build
- run: yarn workspace @hono/cloudflare-access publint
- run: yarn eslint packages/cloudflare-access
- run: yarn test --coverage --project @hono/cloudflare-access
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: cloudflare-access
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-conform-validator
on:
push:
branches: [main]
paths:
- 'packages/conform-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/conform-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/conform-validator
- run: yarn workspace @hono/conform-validator build
- run: yarn workspace @hono/conform-validator publint
- run: yarn eslint packages/conform-validator
- run: yarn test --coverage --project @hono/conform-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: conform-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-effect-validator
on:
push:
branches: [main]
paths:
- 'packages/effect-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/effect-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/effect-validator
- run: yarn workspace @hono/effect-validator build
- run: yarn workspace @hono/effect-validator publint
- run: yarn eslint packages/effect-validator
- run: yarn test --coverage --project @hono/effect-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: effect-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-esbuild-transpiler
on:
push:
branches: [main]
paths:
- 'packages/esbuild-transpiler/**'
pull_request:
branches: ['*']
paths:
- 'packages/esbuild-transpiler/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/esbuild-transpiler
- run: yarn workspace @hono/esbuild-transpiler build
- run: yarn workspace @hono/esbuild-transpiler publint
- run: yarn eslint packages/esbuild-transpiler
- run: yarn test --coverage --project @hono/esbuild-transpiler
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: esbuild-transpiler
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-event-emitter
on:
push:
branches: [main]
paths:
- 'packages/event-emitter/**'
pull_request:
branches: ['*']
paths:
- 'packages/event-emitter/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/event-emitter
- run: yarn workspace @hono/event-emitter build
- run: yarn workspace @hono/event-emitter publint
- run: yarn eslint packages/event-emitter
- run: yarn test --coverage --project @hono/event-emitter
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: event-emitter
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-firebase-auth
on:
push:
branches: [main]
paths:
- 'packages/firebase-auth/**'
pull_request:
branches: ['*']
paths:
- 'packages/firebase-auth/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/firebase-auth
- run: yarn workspace @hono/firebase-auth build
- run: yarn workspace @hono/firebase-auth publint
- run: yarn eslint packages/firebase-auth
- run: yarn test --coverage --project @hono/firebase-auth
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: firebase-auth
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-graphql-server
on:
push:
branches: [main]
paths:
- 'packages/graphql-server/**'
pull_request:
branches: ['*']
paths:
- 'packages/graphql-server/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/graphql-server
- run: yarn workspace @hono/graphql-server build
- run: yarn workspace @hono/graphql-server publint
- run: yarn eslint packages/graphql-server
- run: yarn test --coverage --project @hono/graphql-server
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: graphql-server
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-hello
on:
push:
branches: [main]
paths:
- 'packages/hello/**'
pull_request:
branches: ['*']
paths:
- 'packages/hello/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/hello
- run: yarn workspace @hono/hello build
- run: yarn workspace @hono/hello publint
- run: yarn eslint packages/hello
- run: yarn test --coverage --project @hono/hello
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: hello
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-medley-router
on:
push:
branches: [main]
paths:
- 'packages/medley-router/**'
pull_request:
branches: ['*']
paths:
- 'packages/medley-router/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/medley-router
- run: yarn workspace @hono/medley-router build
- run: yarn workspace @hono/medley-router publint
- run: yarn eslint packages/medley-router
- run: yarn test --coverage --project @hono/medley-router
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: medley-router
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-node-ws
on:
push:
branches: [main]
paths:
- 'packages/node-ws/**'
pull_request:
branches: ['*']
paths:
- 'packages/node-ws/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/node-ws
- run: yarn workspace @hono/node-ws build
- run: yarn workspace @hono/node-ws publint
- run: yarn eslint packages/node-ws
- run: yarn test --coverage --project @hono/node-ws
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: node-ws
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-oauth-providers
on:
push:
branches: [main]
paths:
- 'packages/oauth-providers/**'
pull_request:
branches: ['*']
paths:
- 'packages/oauth-providers/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/oauth-providers
- run: yarn workspace @hono/oauth-providers build
- run: yarn workspace @hono/oauth-providers publint
- run: yarn eslint packages/oauth-providers
- run: yarn test --coverage --project @hono/oauth-providers
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: oauth-providers
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-oidc-auth
on:
push:
branches: [main]
paths:
- 'packages/oidc-auth/**'
pull_request:
branches: ['*']
paths:
- 'packages/oidc-auth/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/oidc-auth
- run: yarn workspace @hono/oidc-auth build
- run: yarn workspace @hono/oidc-auth publint
- run: yarn eslint packages/oidc-auth
- run: yarn test --coverage --project @hono/oidc-auth
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: oidc-auth
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-otel
on:
push:
branches: [main]
paths:
- 'packages/otel/**'
pull_request:
branches: ['*']
paths:
- 'packages/otel/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/otel
- run: yarn workspace @hono/otel build
- run: yarn workspace @hono/otel publint
- run: yarn eslint packages/otel
- run: yarn test --coverage --project @hono/otel
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: otel
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-prometheus
on:
push:
branches: [main]
paths:
- 'packages/prometheus/**'
pull_request:
branches: ['*']
paths:
- 'packages/prometheus/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/prometheus
- run: yarn workspace @hono/prometheus build
- run: yarn workspace @hono/prometheus publint
- run: yarn eslint packages/prometheus
- run: yarn test --coverage --project @hono/prometheus
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: prometheus
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-qwik-city
on:
push:
branches: [main]
paths:
- 'packages/qwik-city/**'
pull_request:
branches: ['*']
paths:
- 'packages/qwik-city/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/qwik-city
- run: yarn workspace @hono/qwik-city build
- run: yarn workspace @hono/qwik-city publint
- run: yarn eslint packages/qwik-city
# - run: yarn test --coverage --project @hono/qwik-city
# - uses: codecov/codecov-action@v5
# with:
# fail_ci_if_error: true
# directory: ./coverage
# flags: qwik-city
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-react-compat
on:
push:
branches: [main]
paths:
- 'packages/react-compat/**'
pull_request:
branches: ['*']
paths:
- 'packages/react-compat/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/react-compat
- run: yarn workspace @hono/react-compat build
- run: yarn workspace @hono/react-compat publint
- run: yarn eslint packages/react-compat
# - run: yarn test --coverage --project @hono/react-compat
# - uses: codecov/codecov-action@v5
# with:
# fail_ci_if_error: true
# directory: ./coverage
# flags: react-compat
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-react-renderer
on:
push:
branches: [main]
paths:
- 'packages/react-renderer/**'
pull_request:
branches: ['*']
paths:
- 'packages/react-renderer/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/react-renderer
- run: yarn workspace @hono/react-renderer build
- run: yarn workspace @hono/react-renderer publint
- run: yarn eslint packages/react-renderer
- run: yarn test --coverage --project @hono/react-renderer
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: react-renderer
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-sentry
on:
push:
branches: [main]
paths:
- 'packages/sentry/**'
pull_request:
branches: ['*']
paths:
- 'packages/sentry/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/sentry
- run: yarn workspace @hono/sentry build
- run: yarn workspace @hono/sentry publint
- run: yarn eslint packages/sentry
- run: yarn test --coverage --project @hono/sentry
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: sentry
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-standard-validator
on:
push:
branches: [main]
paths:
- 'packages/standard-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/standard-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/standard-validator
- run: yarn workspace @hono/standard-validator build
- run: yarn workspace @hono/standard-validator publint
- run: yarn eslint packages/standard-validator
- run: yarn test --coverage --project @hono/standard-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: standard-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-swagger-editor
on:
push:
branches: [main]
paths:
- 'packages/swagger-editor/**'
pull_request:
branches: ['*']
paths:
- 'packages/swagger-editor/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/swagger-editor
- run: yarn workspace @hono/swagger-editor build
- run: yarn workspace @hono/swagger-editor publint
- run: yarn eslint packages/swagger-editor
- run: yarn test --coverage --project @hono/swagger-editor
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: swagger-editor
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-swagger-ui
on:
push:
branches: [main]
paths:
- 'packages/swagger-ui/**'
pull_request:
branches: ['*']
paths:
- 'packages/swagger-ui/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/swagger-ui
- run: yarn workspace @hono/swagger-ui build
- run: yarn workspace @hono/swagger-ui publint
- run: yarn eslint packages/swagger-ui
- run: yarn test --coverage --project @hono/swagger-ui
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: swagger-ui
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-trpc-server
on:
push:
branches: [main]
paths:
- 'packages/trpc-server/**'
pull_request:
branches: ['*']
paths:
- 'packages/trpc-server/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/trpc-server
- run: yarn workspace @hono/trpc-server build
- run: yarn workspace @hono/trpc-server publint
- run: yarn eslint packages/trpc-server
- run: yarn test --coverage --project @hono/trpc-server
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: trpc-server
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-tsyringe
on:
push:
branches: [main]
paths:
- 'packages/tsyringe/**'
pull_request:
branches: ['*']
paths:
- 'packages/tsyringe/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/tsyringe
- run: yarn workspace @hono/tsyringe build
- run: yarn workspace @hono/tsyringe publint
- run: yarn eslint packages/tsyringe
- run: yarn test --coverage --project @hono/tsyringe
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: tsyringe
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-typebox-validator
on:
push:
branches: [main]
paths:
- 'packages/typebox-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/typebox-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/typebox-validator
- run: yarn workspace @hono/typebox-validator build
- run: yarn workspace @hono/typebox-validator publint
- run: yarn eslint packages/typebox-validator
- run: yarn test --coverage --project @hono/typebox-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: typebox-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-typia-validator
on:
push:
branches: [main]
paths:
- 'packages/typia-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/typia-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/typia-validator
- run: yarn workspace @hono/typia-validator build
- run: yarn workspace @hono/typia-validator publint
- run: yarn eslint packages/typia-validator
- run: yarn test --coverage --project @hono/typia-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: typia-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -0,0 +1,42 @@
name: Sync robots.json
on:
schedule:
# Runs every day at midnight
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync-and-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js and Yarn
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'yarn'
- run: yarn workspaces focus hono-middleware @hono/ua-blocker
- name: Fetch latest robots.json
run: yarn workspace @hono/ua-blocker getrobotstxt
- name: Generate data
run: yarn workspace @hono/ua-blocker prebuild
- name: Create Pull Request if changes exist
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore(ua-blocker): update robots.json from upstream'
title: 'chore(ua-blocker): update robots.json from upstream'
body: 'This PR was automatically created after detecting changes in the upstream `robots.json` file.'
branch: 'chore/sync-robots-json'
delete-branch: true
# Assignee and labels
assignees: finxol
reviewers: finxol
labels: robots.json

View File

@ -1,31 +0,0 @@
name: ci-valibot-validator
on:
push:
branches: [main]
paths:
- 'packages/valibot-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/valibot-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/valibot-validator
- run: yarn workspace @hono/valibot-validator build
- run: yarn workspace @hono/valibot-validator publint
- run: yarn eslint packages/valibot-validator
- run: yarn test --coverage --project @hono/valibot-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: valibot-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-zod-openapi
on:
push:
branches: [main]
paths:
- 'packages/zod-openapi/**'
pull_request:
branches: ['*']
paths:
- 'packages/zod-openapi/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/zod-openapi
- run: yarn workspaces foreach --topological --recursive --from @hono/zod-openapi run build
- run: yarn workspace @hono/zod-openapi publint
- run: yarn eslint packages/zod-openapi
- run: yarn test --coverage --project @hono/zod-openapi
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: zod-openapi
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -1,31 +0,0 @@
name: ci-zod-validator
on:
push:
branches: [main]
paths:
- 'packages/zod-validator/**'
pull_request:
branches: ['*']
paths:
- 'packages/zod-validator/**'
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/zod-validator
- run: yarn workspace @hono/zod-validator build
- run: yarn workspace @hono/zod-validator publint
- run: yarn eslint packages/zod-validator
- run: yarn test --coverage --project @hono/zod-validator
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
directory: ./coverage
flags: zod-validator
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

74
.github/workflows/ci.yml vendored 100644
View File

@ -0,0 +1,74 @@
name: ci
on:
push:
branches: [main]
pull_request:
branches: ['*']
jobs:
what-changed:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set-packages.outputs.packages }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Get changed packages
id: set-packages
run: |
exclude=(
"hono-middleware"
"@hono/bun-transpiler"
);
changed=$(yarn workspaces list --json --since | jq -nc '[inputs.name | select(any(.; inside($ARGS.positional[])) | not) | sub("@hono/"; "")]' --args "${exclude[@]}")
echo "packages=${changed}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: [what-changed]
if: ${{ needs.what-changed.outputs.packages != '[]' }}
strategy:
matrix:
package: ${{ fromJSON(needs.what-changed.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/${{ matrix.package }}
- run: yarn workspaces foreach --topological --recursive --from @hono/${{ matrix.package }} run publint
- run: yarn workspace @hono/${{ matrix.package }} typecheck
- run: yarn eslint packages/${{ matrix.package }}
- run: yarn prettier --check . !packages packages/${{ matrix.package }}
test:
runs-on: ubuntu-latest
needs: [what-changed]
if: ${{ needs.what-changed.outputs.packages != '[]' }}
strategy:
matrix:
package: ${{ fromJSON(needs.what-changed.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn workspaces focus hono-middleware @hono/${{ matrix.package }}
- run: yarn workspaces foreach --topological --recursive --from @hono/${{ matrix.package }} run build
- run: yarn test --coverage --project @hono/${{ matrix.package }}
id: test
if: ${{ matrix.package != 'qwik-city' && matrix.package != 'react-compat' }}
- uses: codecov/codecov-action@v5
if: ${{ matrix.package != 'qwik-city' && matrix.package != 'react-compat' }}
with:
fail_ci_if_error: true
directory: ./coverage
flags: ${{ matrix.package }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -26,11 +26,17 @@ jobs:
- name: Build
run: yarn build
- name: Set NPM Auth Token
run: yarn config set npmAuthToken ${NPM_TOKEN}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn changeset publish
publish: yarn run publish
version: yarn changeset version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

11
.gitignore vendored
View File

@ -3,7 +3,7 @@ dist
node_modules
*.tgz
coverage
.eslintcache
.yarn/*
!.yarn/cache
!.yarn/patches
@ -15,4 +15,11 @@ yarn-error.log
# for debug or playing
sandbox
*.log
*.log
# Claude Code local files
CLAUDE.local.md
settings.local.json
# Code editor
.zed

9
.prettierignore 100644
View File

@ -0,0 +1,9 @@
.changeset
.vscode
.yarn
# Casbin
*.conf
*.csv
**/generated.ts

File diff suppressed because one or more lines are too long

942
.yarn/releases/yarn-4.9.2.cjs vendored 100755

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
nmHoistingLimits: workspaces
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.0.2.cjs
nmHoistingLimits: 'workspaces'
yarnPath: .yarn/releases/yarn-4.9.2.cjs

View File

@ -1,6 +1,61 @@
import baseConfig from '@hono/eslint-config'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig(globalIgnores(['.yarn', '**/dist']), {
export default defineConfig(globalIgnores(['.yarn', '**/coverage', '**/dist']), {
extends: baseConfig,
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'error',
reportUnusedInlineConfigs: 'error',
},
rules: {
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-function-type': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/prefer-return-this-type': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off',
},
})

View File

@ -8,13 +8,17 @@
]
},
"scripts": {
"build": "yarn workspaces foreach --all --parallel --topological --verbose run build",
"publint": "yarn workspaces foreach --all --parallel --topological --verbose run publint",
"build": "yarn workspaces foreach --all --topological --verbose run build",
"publint": "yarn workspaces foreach --all --topological --verbose run publint",
"publish": "yarn workspaces foreach --all --no-private --topological --verbose npm publish --tolerate-republish && changeset tag",
"typecheck": "yarn tsc --build",
"typecheck:clean": "yarn tsc --build --clean",
"typecheck:watch": "yarn tsc --build --watch",
"test": "vitest",
"lint": "eslint 'packages/**/*.{ts,tsx}'",
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
"format": "prettier --check 'packages/**/*.{ts,tsx}'",
"format:fix": "prettier --write 'packages/**/*.{ts,tsx}'"
"format": "prettier --check .",
"format:fix": "prettier --write ."
},
"license": "MIT",
"private": true,
@ -29,17 +33,16 @@
"@cloudflare/workers-types": "^4.20230307.0",
"@hono/eslint-config": "workspace:*",
"@ryoppippi/unplugin-typia": "^1.2.0",
"@types/node": "^20.14.8",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@types/bun": "^1.0.0",
"@types/node": "^20.17.28",
"@types/ws": "^8.18.0",
"@vitest/coverage-istanbul": "^3.0.8",
"eslint": "^9.17.0",
"hono": "^4.7.5",
"npm-run-all2": "^6.2.2",
"prettier": "^2.7.1",
"eslint": "^9.23.0",
"hono": "^4.7.11",
"prettier": "^3.5.3",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@4.9.2"
}

View File

@ -12,6 +12,7 @@
"build": "tsup ./src/index.ts",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"exports": {
@ -43,9 +44,10 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"ajv": ">=8.12.0",
"ajv": "^8.12.0",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
}
}

View File

@ -1,5 +1,6 @@
import type { JSONSchemaType, type ErrorObject } from 'ajv'
import type { JSONSchemaType, ErrorObject } from 'ajv'
import { Hono } from 'hono'
import type { ContentfulStatusCode } from 'hono/utils/http-status'
import type { Equal, Expect } from 'hono/utils/types'
import { ajvValidator } from '.'
@ -40,6 +41,8 @@ describe('Basic', () => {
success: boolean
message: string
}
outputFormat: 'json'
status: ContentfulStatusCode
}
}
}

View File

@ -67,7 +67,7 @@ export function ajvValidator<
T,
Target extends keyof ValidationTargets,
E extends Env = Env,
P extends string = string
P extends string = string,
>(
target: Target,
schema: JSONSchemaType<T>,

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,6 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/ajv-validator",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -1,5 +1,11 @@
# @hono/arktype-validator
## 2.0.1
### Patch Changes
- [#1137](https://github.com/honojs/middleware/pull/1137) [`01cd896e9b3c6a00c3c16ed59e0c3d20f5983918`](https://github.com/honojs/middleware/commit/01cd896e9b3c6a00c3c16ed59e0c3d20f5983918) Thanks [@MonsterDeveloper](https://github.com/MonsterDeveloper)! - Don't return restricted data fields on error responses
## 2.0.0
### Major Changes

View File

@ -1,6 +1,6 @@
{
"name": "@hono/arktype-validator",
"version": "2.0.0",
"version": "2.0.1",
"description": "ArkType validator middleware",
"type": "module",
"main": "dist/index.js",
@ -13,6 +13,7 @@
"build": "tsup ./src/index.ts",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"exports": {
@ -47,6 +48,7 @@
"arktype": "^2.0.0-dev.14",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
}
}

View File

@ -1,5 +1,6 @@
import { type } from 'arktype'
import { Hono } from 'hono'
import type { ContentfulStatusCode } from 'hono/utils/http-status'
import type { Equal, Expect } from 'hono/utils/types'
import { arktypeValidator } from '.'
@ -34,6 +35,17 @@ describe('Basic', () => {
}
)
app.get(
'/headers',
arktypeValidator(
'header',
type({
'User-Agent': 'string',
})
),
(c) => c.json({ success: true, userAgent: c.header('User-Agent') })
)
type Actual = ExtractSchema<typeof route>
type Expected = {
'/author': {
@ -53,6 +65,8 @@ describe('Basic', () => {
message: string
queryName: string | undefined
}
outputFormat: 'json'
status: ContentfulStatusCode
}
}
}
@ -95,6 +109,22 @@ describe('Basic', () => {
const data = (await res.json()) as { success: boolean }
expect(data['success']).toBe(false)
})
it("doesn't return cookies after headers validation", async () => {
const req = new Request('http://localhost/headers', {
headers: {
'User-Agent': 'invalid',
Cookie: 'SECRET=123',
},
})
const res = await app.request(req)
expect(res).not.toBeNull()
expect(res.status).toBe(400)
const data = (await res.json()) as { succcess: false; errors: type.errors }
expect(data.errors).toHaveLength(1)
expect(data.errors[0].data).not.toHaveProperty('cookie')
})
})
describe('With Hook', () => {

View File

@ -10,6 +10,10 @@ export type Hook<T, E extends Env, P extends string, O = {}> = (
type HasUndefined<T> = undefined extends T ? true : false
const RESTRICTED_DATA_FIELDS = {
header: ['cookie'],
}
export const arktypeValidator = <
T extends Type,
Target extends keyof ValidationTargets,
@ -23,7 +27,7 @@ export const arktypeValidator = <
} = {
in: HasUndefined<I> extends true ? { [K in Target]?: I } : { [K in Target]: I }
out: { [K in Target]: O }
}
},
>(
target: Target,
schema: T,
@ -54,7 +58,31 @@ export const arktypeValidator = <
return c.json(
{
success: false,
errors: out,
errors:
target in RESTRICTED_DATA_FIELDS
? out.map((error) => {
const restrictedFields =
RESTRICTED_DATA_FIELDS[target as keyof typeof RESTRICTED_DATA_FIELDS] || []
if (
error &&
typeof error === 'object' &&
'data' in error &&
typeof error.data === 'object' &&
error.data !== null &&
!Array.isArray(error.data)
) {
const dataCopy = { ...(error.data as Record<string, unknown>) }
for (const field of restrictedFields) {
delete dataCopy[field]
}
error.data = dataCopy
}
return error
})
: out,
},
400
)

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,6 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/arktype-validator",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -1,5 +1,17 @@
# @hono/auth-js
## 1.0.17
### Patch Changes
- [#1210](https://github.com/honojs/middleware/pull/1210) [`0758fd0af1f213131d0894299e5bec716d284580`](https://github.com/honojs/middleware/commit/0758fd0af1f213131d0894299e5bec716d284580) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Add explicit return types
## 1.0.16
### Patch Changes
- [#1170](https://github.com/honojs/middleware/pull/1170) [`7585969171ad4876e7620c7369eb9b638849d0eb`](https://github.com/honojs/middleware/commit/7585969171ad4876e7620c7369eb9b638849d0eb) Thanks [@hambergerpls](https://github.com/hambergerpls)! - fix(auth-js): use HonoRequest.blob() instead of HonoRequest.raw.body()
## 1.0.15
### Patch Changes

View File

@ -1,6 +1,6 @@
{
"name": "@hono/auth-js",
"version": "1.0.15",
"version": "1.0.17",
"description": "A third-party Auth js middleware for Hono",
"main": "dist/index.js",
"type": "module",
@ -40,6 +40,7 @@
"build": "tsup src/index.ts src/react.tsx",
"prepack": "yarn build",
"publint": "attw --pack --profile node16 && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"license": "MIT",
@ -65,6 +66,7 @@
"publint": "^0.3.9",
"react": "^18.2.0",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
},
"engines": {

View File

@ -134,7 +134,7 @@ export async function fetchData<T = any>(
}
}
export function useOnline() {
export function useOnline(): boolean {
const [isOnline, setIsOnline] = useState(
typeof navigator !== 'undefined' ? navigator.onLine : false
)
@ -157,11 +157,19 @@ export function useOnline() {
return isOnline
}
export function now() {
export function now(): number {
return Math.floor(Date.now() / 1000)
}
export function parseUrl(url?: string) {
interface ParsedUrl {
origin: string
host: string
path: string
base: string
toString: () => string
}
export function parseUrl(url?: string): ParsedUrl {
const defaultUrl = 'http://localhost:3000/api/auth'
const parsedUrl = new URL(url ? (url.startsWith('http') ? url : `https://${url}`) : defaultUrl)
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')

View File

@ -2,6 +2,7 @@ import { skipCSRFCheck } from '@auth/core'
import type { Adapter } from '@auth/core/adapters'
import Credentials from '@auth/core/providers/credentials'
import { Hono } from 'hono'
import { validator } from 'hono/validator'
import { describe, expect, it, vi } from 'vitest'
import type { AuthConfig } from '.'
import { authHandler, verifyAuth, initAuthConfig, reqWithEnvUrl } from '.'
@ -80,6 +81,128 @@ describe('reqWithEnvUrl()', async () => {
it('Should rewrite the base path', () => {
expect(newReq.url.toString()).toBe('https://auth-url-base/request-path')
})
const mockAdapter: Adapter = {
createVerificationToken: vi.fn(),
useVerificationToken: vi.fn(),
getUserByEmail: vi.fn(),
createUser: vi.fn(),
getUser: vi.fn(),
getUserByAccount: vi.fn(),
updateUser: vi.fn(),
linkAccount: vi.fn(),
createSession: vi.fn(),
getSessionAndUser: vi.fn(),
updateSession: vi.fn(),
deleteSession: vi.fn(),
}
globalThis.process.env = {
AUTH_SECRET: 'secret',
}
const user = { email: 'hono@hono.hono', name: 'Hono' }
const credentials = Credentials({
credentials: {
password: {},
},
authorize: (credentials) => {
if (credentials.password === 'password') {
return user
}
return null
},
})
function getAuthConfig(): AuthConfig {
return {
secret: 'secret',
providers: [credentials],
adapter: mockAdapter,
basePath: '/api/auth',
callbacks: {
jwt: ({ token, user }) => {
if (user) {
token.id = user.id
}
return token
},
},
session: {
strategy: 'jwt',
},
}
}
let cookie = ['']
it('Should be able to instantiate new Request after passing through validator', async () => {
const app = new Hono()
app.use('*', initAuthConfig(getAuthConfig))
app.use(
'/api/auth/*',
validator('form', (value, _) => {
const csrfToken = value['csrfToken']
return {
csrfToken,
}
}),
authHandler()
)
let csrfRes = await app.request('http://localhost/api/auth/csrf', {
method: 'GET',
})
let { csrfToken } = await csrfRes.json()
cookie = csrfRes.headers.getSetCookie()
let headers = new Headers()
headers.append('cookie', cookie[0])
const signInRes = await app.request('http://localhost/api/auth/callback/credentials', {
method: 'POST',
headers,
body: new URLSearchParams({
csrfToken,
password: 'password',
}),
})
expect(signInRes.status).toBe(302)
expect(signInRes.headers.get('location')).toBe('http://localhost')
cookie = signInRes.headers.getSetCookie()
const sessionCookie = cookie[1]
headers = new Headers()
headers.append('cookie', cookie[1])
headers.append('Content-Type', 'application/json')
csrfRes = await app.request('http://localhost/api/auth/csrf', {
method: 'GET',
})
;({ csrfToken } = await csrfRes.json())
cookie = csrfRes.headers.getSetCookie()
headers = new Headers()
headers.append('cookie', cookie[0])
headers.append('cookie', sessionCookie)
const req = new Request('http://localhost/api/auth/signout', {
method: 'POST',
body: new URLSearchParams({
csrfToken,
password: 'password',
}),
headers,
})
const res = await app.request(req)
expect(res.status).toBe(302)
})
})
describe('Credentials Provider', () => {

View File

@ -31,12 +31,12 @@ export interface AuthConfig extends Omit<AuthConfigCore, 'raw'> {}
export type ConfigHandler = (c: Context) => AuthConfig
export function setEnvDefaults(env: AuthEnv, config: AuthConfig) {
export function setEnvDefaults(env: AuthEnv, config: AuthConfig): void {
config.secret ??= env.AUTH_SECRET
coreSetEnvDefaults(env, config)
}
export function reqWithEnvUrl(req: Request, authUrl?: string) {
export function reqWithEnvUrl(req: Request, authUrl?: string): Request {
if (authUrl) {
const reqUrlObj = new URL(req.url)
const authUrlObj = new URL(authUrl)
@ -135,7 +135,27 @@ export function authHandler(): MiddlewareHandler {
throw new HTTPException(500, { message: 'Missing AUTH_SECRET' })
}
const res = await Auth(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config)
const body = c.req.raw.body ? await c.req.blob() : undefined
const res = await Auth(
reqWithEnvUrl(
new Request(c.req.raw.url, {
body,
cache: c.req.raw.cache,
credentials: c.req.raw.credentials,
headers: c.req.raw.headers,
integrity: c.req.raw.integrity,
keepalive: c.req.raw.keepalive,
method: c.req.raw.method,
mode: c.req.raw.mode,
redirect: c.req.raw.redirect,
referrer: c.req.raw.referrer,
referrerPolicy: c.req.raw.referrerPolicy,
signal: c.req.raw.signal,
}),
ctxEnv.AUTH_URL
),
config
)
return new Response(res.body, res)
}
}

View File

@ -65,9 +65,11 @@ class AuthConfigManager {
}
}
export const authConfigManager = AuthConfigManager.getInstance()
export const authConfigManager: AuthConfigManager = AuthConfigManager.getInstance()
export const SessionContext = React.createContext<SessionContextValue | undefined>(undefined)
export const SessionContext: React.Context<SessionContextValue | undefined> = React.createContext<
SessionContextValue | undefined
>(undefined)
function useInitializeSession(hasInitialSession: boolean, initialSession: Session | null) {
const authConfig = authConfigManager.getConfig()
@ -148,7 +150,7 @@ function useRefetchInterval(
}, [refetchInterval, shouldRefetch])
}
export async function getSession(params?: GetSessionParams) {
export async function getSession(params?: GetSessionParams): Promise<Session | null> {
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
const session = await fetchData<Session>(
'session',
@ -163,7 +165,7 @@ export async function getSession(params?: GetSessionParams) {
return session
}
export async function getCsrfToken() {
export async function getCsrfToken(): Promise<string> {
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
const response = await fetchData<{ csrfToken: string }>(
'csrf',
@ -177,7 +179,7 @@ export async function getCsrfToken() {
return response?.csrfToken ?? ''
}
export function SessionProvider(props: SessionProviderProps) {
export function SessionProvider(props: SessionProviderProps): React.JSX.Element {
if (!SessionContext) {
throw new Error('React Context is unavailable in Server Components')
}
@ -225,7 +227,7 @@ export function SessionProvider(props: SessionProviderProps) {
}
return updatedSession
},
} as SessionContextValue),
}) as SessionContextValue,
[session, loading, setSession]
)
@ -274,7 +276,7 @@ export function useSession<R extends boolean>(
type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>
export async function getProviders() {
export async function getProviders(): Promise<ProvidersType | null> {
return fetchData<ProvidersType>('providers', authConfigManager.getConfig(), logger)
}
@ -395,10 +397,14 @@ interface PopupLoginOptions extends Partial<Omit<WindowProps, 'url'>> {
callbackUrl?: string
}
interface LoginState extends AuthState {
popUpSignin: () => Promise<void>
}
export const useOauthPopupLogin = (
provider: Parameters<typeof signIn>[0],
options: PopupLoginOptions = {}
) => {
): LoginState => {
const { width = 500, height = 500, title = 'Signin', onSuccess, callbackUrl = '/' } = options
const [externalWindow, setExternalWindow] = useState<Window | null>()

View File

@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true,
"jsx": "react"
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,11 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"outDir": "./dist",
"jsx": "react",
"types": ["node", "vitest/globals"]
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/auth-js",
"jsx": "react"
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -0,0 +1,7 @@
# @hono/bun-compress
## 0.1.0
### Minor Changes
- [#1153](https://github.com/honojs/middleware/pull/1153) [`7717755dd35aec882b452f91373439d357eb516c`](https://github.com/honojs/middleware/commit/7717755dd35aec882b452f91373439d357eb516c) Thanks [@nrdobie](https://github.com/nrdobie)! - Created Bun Compress Middleware

View File

@ -0,0 +1,30 @@
# Bun Compress Middleware for Hono
Bun does not currently support the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) so this middleware replicates the behavior of [`hono/compress`](https://hono.dev/docs/middleware/builtin/compress) using the Zlib library. This middleware will be deprecated once [Bun adds support for `CompressionStream`](https://github.com/oven-sh/bun/issues/1723).
This middleware will use `hono/compress` if CompressionStream is available so you can use this middleware in Bun and Node.js without any changes.
## Import
```ts
import { Hono } from 'hono'
import { compress } from '@hono/bun-compress'
```
## Usage
```ts
const app = new Hono()
app.use(compress())
```
## Options
### <Badge type="info" text="optional" /> encoding: `'gzip'` | `'deflate'`
The compression scheme to allow for response compression. Either `gzip` or `deflate`. If not defined, both are allowed and will be used based on the `Accept-Encoding` header. `gzip` is prioritized if this option is not provided and the client provides both in the `Accept-Encoding` header.
### <Badge type="info" text="optional" /> threshold: `number`
The minimum size in bytes to compress. Defaults to 1024 bytes.

View File

@ -0,0 +1,53 @@
{
"name": "@hono/bun-compress",
"version": "0.1.0",
"description": "A Hono middleware for compressing responses using Bun's built-in compression.",
"type": "module",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsup ./src/index.ts",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "bun test"
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"license": "MIT",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/honojs/middleware.git",
"directory": "packages/bun-compress"
},
"homepage": "https://github.com/honojs/middleware",
"peerDependencies": {
"hono": "*"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@types/bun": "^1.2.12",
"@types/node": "^22.15.15",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
}
}

View File

@ -0,0 +1,231 @@
import { Hono } from 'hono'
import { stream, streamSSE } from 'hono/streaming'
import { Readable } from 'node:stream'
import type { ReadableStream } from 'node:stream/web'
import { createGunzip } from 'node:zlib'
import { compress } from '.'
describe('Bun Compress Middleware', () => {
const app = new Hono()
// Apply compress middleware to all routes
app.use('*', compress())
// Test routes
app.get('/small', (c) => {
c.header('Content-Type', 'text/plain')
c.header('Content-Length', '5')
return c.text('small')
})
app.get('/large', (c) => {
c.header('Content-Type', 'text/plain')
c.header('Content-Length', '1024')
return c.text('a'.repeat(1024))
})
app.get('/small-json', (c) => {
c.header('Content-Type', 'application/json')
c.header('Content-Length', '26')
return c.json({ message: 'Hello, World!' })
})
app.get('/large-json', (c) => {
c.header('Content-Type', 'application/json')
c.header('Content-Length', '1024')
return c.json({ data: 'a'.repeat(1024), message: 'Large JSON' })
})
app.get('/no-transform', (c) => {
c.header('Content-Type', 'text/plain')
c.header('Content-Length', '1024')
c.header('Cache-Control', 'no-transform')
return c.text('a'.repeat(1024))
})
app.get('/jpeg-image', (c) => {
c.header('Content-Type', 'image/jpeg')
c.header('Content-Length', '1024')
return c.body(new Uint8Array(1024)) // Simulated JPEG data
})
app.get('/already-compressed', (c) => {
c.header('Content-Type', 'application/octet-stream')
c.header('Content-Encoding', 'br')
c.header('Content-Length', '1024')
return c.body(new Uint8Array(1024)) // Simulated compressed data
})
app.get('/transfer-encoding-deflate', (c) => {
c.header('Content-Type', 'application/octet-stream')
c.header('Transfer-Encoding', 'deflate')
c.header('Content-Length', '1024')
return c.body(new Uint8Array(1024)) // Simulated deflate data
})
app.get('/chunked', (c) => {
c.header('Content-Type', 'application/octet-stream')
c.header('Transfer-Encoding', 'chunked')
c.header('Content-Length', '1024')
return c.body(new Uint8Array(1024)) // Simulated chunked data
})
app.get('/stream', (c) =>
stream(c, async (stream) => {
c.header('Content-Type', 'text/plain')
// 60000 bytes
for (let i = 0; i < 10000; i++) {
await stream.write('chunk ')
}
})
)
app.get('/already-compressed-stream', (c) =>
stream(c, async (stream) => {
c.header('Content-Type', 'text/plain')
c.header('Content-Encoding', 'br')
// 60000 bytes
for (let i = 0; i < 10000; i++) {
await stream.write(new Uint8Array([0, 1, 2, 3, 4, 5])) // Simulated compressed data
}
})
)
app.get('/sse', (c) =>
streamSSE(c, async (stream) => {
for (let i = 0; i < 1000; i++) {
await stream.writeSSE({ data: 'chunk' })
}
})
)
app.notFound((c) => c.text('Custom NotFound', 404))
const testCompression = async (
path: string,
acceptEncoding: string,
expectedEncoding: string | null
) => {
const req = new Request(`http://localhost${path}`, {
method: 'GET',
headers: new Headers({ 'Accept-Encoding': acceptEncoding }),
})
const res = await app.request(req)
expect(res.headers.get('Content-Encoding')).toBe(expectedEncoding)
return res
}
describe('Compression Behavior', () => {
it('should compress large responses with gzip', async () => {
const res = await testCompression('/large', 'gzip', 'gzip')
expect(res.headers.get('Content-Length')).toBeNull()
expect((await res.arrayBuffer()).byteLength).toBeLessThan(1024)
})
it('should compress large responses with deflate', async () => {
const res = await testCompression('/large', 'deflate', 'deflate')
expect((await res.arrayBuffer()).byteLength).toBeLessThan(1024)
})
it('should prioritize gzip over deflate when both are accepted', async () => {
await testCompression('/large', 'gzip, deflate', 'gzip')
})
it('should not compress small responses', async () => {
const res = await testCompression('/small', 'gzip, deflate', null)
expect(res.headers.get('Content-Length')).toBe('5')
})
it('should not compress when no Accept-Encoding is provided', async () => {
await testCompression('/large', '', null)
})
it('should not compress images', async () => {
const res = await testCompression('/jpeg-image', 'gzip', null)
expect(res.headers.get('Content-Type')).toBe('image/jpeg')
expect(res.headers.get('Content-Length')).toBe('1024')
})
it('should not compress already compressed responses', async () => {
const res = await testCompression('/already-compressed', 'gzip', 'br')
expect(res.headers.get('Content-Length')).toBe('1024')
})
it('should remove Content-Length when compressing', async () => {
const res = await testCompression('/large', 'gzip', 'gzip')
expect(res.headers.get('Content-Length')).toBeNull()
})
it('should not remove Content-Length when not compressing', async () => {
const res = await testCompression('/jpeg-image', 'gzip', null)
expect(res.headers.get('Content-Length')).toBeDefined()
})
it('should not compress transfer-encoding: deflate', async () => {
const res = await testCompression('/transfer-encoding-deflate', 'gzip', null)
expect(res.headers.get('Content-Length')).toBe('1024')
expect(res.headers.get('Transfer-Encoding')).toBe('deflate')
})
it('should not compress transfer-encoding: chunked', async () => {
const res = await testCompression('/chunked', 'gzip', null)
expect(res.headers.get('Content-Length')).toBe('1024')
expect(res.headers.get('Transfer-Encoding')).toBe('chunked')
})
})
describe('JSON Handling', () => {
it('should not compress small JSON responses', async () => {
const res = await testCompression('/small-json', 'gzip', null)
expect(res.headers.get('Content-Length')).toBe('26')
})
it('should compress large JSON responses', async () => {
const res = await testCompression('/large-json', 'gzip', 'gzip')
expect(res.headers.get('Content-Length')).toBeNull()
const decompressed = await decompressResponse(res)
const json = JSON.parse(decompressed)
expect(json.data.length).toBe(1024)
expect(json.message).toBe('Large JSON')
})
})
describe('Streaming Responses', () => {
it('should compress streaming responses written in multiple chunks', async () => {
const res = await testCompression('/stream', 'gzip', 'gzip')
const decompressed = await decompressResponse(res)
expect(decompressed.length).toBe(60000)
})
it('should not compress already compressed streaming responses', async () => {
const res = await testCompression('/already-compressed-stream', 'gzip', 'br')
expect((await res.arrayBuffer()).byteLength).toBe(60000)
})
it('should not compress server-sent events', async () => {
const res = await testCompression('/sse', 'gzip', null)
expect((await res.arrayBuffer()).byteLength).toBe(13000)
})
})
describe('Edge Cases', () => {
it('should not compress responses with Cache-Control: no-transform', async () => {
await testCompression('/no-transform', 'gzip', null)
})
it('should handle HEAD requests without compression', async () => {
const req = new Request('http://localhost/large', {
method: 'HEAD',
headers: new Headers({ 'Accept-Encoding': 'gzip' }),
})
const res = await app.request(req)
expect(res.headers.get('Content-Encoding')).toBeNull()
})
it('should compress custom 404 Not Found responses', async () => {
const res = await testCompression('/not-found', 'gzip', 'gzip')
expect(res.status).toBe(404)
const decompressed = await decompressResponse(res)
expect(decompressed).toBe('Custom NotFound')
})
})
})
async function decompressResponse(res: Response): Promise<string> {
const resBody = res.body as ReadableStream
const readableStream = Readable.fromWeb(resBody)
const decompressedStream = readableStream.pipe(createGunzip())
const decompressedReadableStream = Readable.toWeb(decompressedStream)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const decompressedResponse = new Response(decompressedReadableStream as any)
return await decompressedResponse.text()
}

View File

@ -0,0 +1,103 @@
/**
* @module
* Compress Middleware for Hono.
*/
import type { MiddlewareHandler } from 'hono'
import { compress as originalCompress } from 'hono/compress'
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from 'hono/utils/compress'
import { Readable } from 'node:stream'
import type { ReadableStream } from 'node:stream/web'
import { createDeflate, createGzip } from 'node:zlib'
const ENCODING_TYPES = ['gzip', 'deflate'] as const
const cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i
interface CompressionOptions {
encoding?: (typeof ENCODING_TYPES)[number]
threshold?: number
}
/**
* Compress Middleware for Hono on Bun.
*
* Bun does not currently support CompressionStream, so this uses the zlib module to compress the response body.
*
* @see {@link https://hono.dev/docs/middleware/builtin/compress}
* @see {@link https://github.com/oven-sh/bun/issues/1723}
*
* @param {CompressionOptions} [options] - The options for the compress middleware.
* @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
* @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(bunCompress())
* ```
*/
export const compress = (options?: CompressionOptions): MiddlewareHandler => {
// Check CompressionStream support
if (typeof CompressionStream !== 'undefined') {
return originalCompress(options)
}
const threshold = options?.threshold ?? 1024
return async function compress(ctx, next) {
await next()
const contentLength = ctx.res.headers.get('Content-Length')
// Check if response should be compressed
if (
ctx.res.headers.has('Content-Encoding') || // already encoded
ctx.res.headers.has('Transfer-Encoding') || // already encoded or chunked
ctx.req.method === 'HEAD' || // HEAD request
(contentLength && Number(contentLength) < threshold) || // content-length below threshold
!shouldCompress(ctx.res) || // not compressible type
!shouldTransform(ctx.res) // cache-control: no-transform
) {
return
}
const accepted = ctx.req.header('Accept-Encoding')
const encoding =
options?.encoding ?? ENCODING_TYPES.find((encoding) => accepted?.includes(encoding))
if (!encoding || !ctx.res.body) {
return
}
// Compress the response
try {
const compressedStream = encoding === 'gzip' ? createGzip() : createDeflate()
const readableBody = ctx.res.body as ReadableStream
const readableStream = Readable.fromWeb(readableBody)
const compressedBody = readableStream.pipe(compressedStream)
const compressedReadableStream = Readable.toWeb(compressedBody) as ReadableStream<Uint8Array>
// Create a new response with the compressed body
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ctx.res = new Response(compressedReadableStream as any, ctx.res)
ctx.res.headers.delete('Content-Length')
ctx.res.headers.set('Content-Encoding', encoding)
} catch (error) {
console.error('Compression error:', error)
}
}
}
const shouldCompress = (res: Response) => {
const type = res.headers.get('Content-Type')
return type && COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type)
}
const shouldTransform = (res: Response) => {
const cacheControl = res.headers.get('Cache-Control')
// Don't compress for Cache-Control: no-transform
// https://tools.ietf.org/html/rfc7234#section-5.2.2.4
return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl)
}

View File

@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true,
"types": ["node", "bun"]
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -0,0 +1,12 @@
{
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/hello",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -0,0 +1,7 @@
import { defineProject } from 'vitest/config'
export default defineProject({
test: {
globals: true,
},
})

View File

@ -1,5 +1,11 @@
# @hono/bun-transpiler
## 0.2.1
### Patch Changes
- [#1193](https://github.com/honojs/middleware/pull/1193) [`1adca4c91822af8f68f4a134344cca93e0796ad0`](https://github.com/honojs/middleware/commit/1adca4c91822af8f68f4a134344cca93e0796ad0) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Add explicit `MiddlewareHandler` return type
## 0.2.0
### Minor Changes

View File

@ -1,6 +1,6 @@
{
"name": "@hono/bun-transpiler",
"version": "0.2.0",
"version": "0.2.1",
"description": "Bun Transpiler Middleware for Hono",
"type": "module",
"main": "dist/index.js",
@ -13,6 +13,7 @@
"build": "tsup ./src/index.ts --external bun",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "bun test"
},
"exports": {
@ -43,9 +44,9 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@types/bun": "^1.0.0",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
},
"engines": {

View File

@ -1,4 +1,5 @@
import Bun from 'bun'
import type { MiddlewareHandler } from 'hono'
import { createMiddleware } from 'hono/factory'
type BunTranspilerOptions = {
@ -16,7 +17,7 @@ export const defaultOptions: Required<BunTranspilerOptions> = {
},
}
export const bunTranspiler = (options?: BunTranspilerOptions) => {
export const bunTranspiler = (options?: BunTranspilerOptions): MiddlewareHandler => {
return createMiddleware(async (c, next) => {
await next()
const url = new URL(c.req.url)

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,6 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/bun-transpiler",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -35,6 +35,7 @@
"build": "tsup ./src/index.ts ./src/helper/index.ts",
"prepack": "yarn build",
"publint": "attw --pack --profile node16 && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"license": "MIT",
@ -57,6 +58,7 @@
"casbin": "^5.30.0",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
}
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["./src/**/*.ts"],
"references": []
}

View File

@ -1,6 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": true
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/casbin",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts", "vitest.setup.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -26,6 +26,7 @@
"build": "tsup ./src/index.ts",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"license": "MIT",
@ -46,6 +47,7 @@
"@arethetypeswrong/cli": "^0.17.4",
"publint": "^0.3.9",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
},
"dependencies": {

View File

@ -3,6 +3,7 @@ import type { ValidationError } from 'class-validator'
import { IsInt, IsString, ValidateNested } from 'class-validator'
import { Hono } from 'hono'
import type { ExtractSchema } from 'hono/types'
import type { ContentfulStatusCode } from 'hono/utils/http-status'
import type { Equal, Expect } from 'hono/utils/types'
import { classValidator } from '.'
@ -39,6 +40,8 @@ describe('Basic', () => {
success: boolean
message: string
}
outputFormat: 'json'
status: ContentfulStatusCode
}
}
}

View File

@ -64,7 +64,7 @@ type Hook<
E extends Env,
P extends string,
Target extends keyof ValidationTargets = keyof ValidationTargets,
O = object
O = object,
> = (
result: ({ success: true } | { success: false; errors: ValidationError[] }) & {
data: T
@ -119,19 +119,19 @@ export const classValidator = <
[K in Target]?: K extends 'json'
? In
: HasUndefined<keyof ValidationTargets[K]> extends true
? { [K2 in keyof In]?: ValidationTargets[K][K2] }
: { [K2 in keyof In]: ValidationTargets[K][K2] }
? { [K2 in keyof In]?: ValidationTargets[K][K2] }
: { [K2 in keyof In]: ValidationTargets[K][K2] }
}
: {
[K in Target]: K extends 'json'
? In
: HasUndefined<keyof ValidationTargets[K]> extends true
? { [K2 in keyof In]?: ValidationTargets[K][K2] }
: { [K2 in keyof In]: ValidationTargets[K][K2] }
? { [K2 in keyof In]?: ValidationTargets[K][K2] }
: { [K2 in keyof In]: ValidationTargets[K][K2] }
}
out: { [K in Target]: Output }
},
V extends I = I
V extends I = I,
>(
target: Target,
dataType: T,

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,8 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/class-validator",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["vitest/globals"],
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}

View File

@ -4,7 +4,8 @@ export default defineProject({
test: {
globals: true,
typecheck: {
tsconfig: './tsconfig.vitest.json',
tsconfig: './tsconfig.json',
enabled: true,
},
},
})

View File

@ -1,5 +1,11 @@
# @hono/clerk-auth
## 2.0.1
### Patch Changes
- [#1194](https://github.com/honojs/middleware/pull/1194) [`683455895d35de50bd5c4cc60c0d764b99a8c8ec`](https://github.com/honojs/middleware/commit/683455895d35de50bd5c4cc60c0d764b99a8c8ec) Thanks [@BarryThePenguin](https://github.com/BarryThePenguin)! - Add explicit `MiddlewareHandler` return type
## 2.0.0
### Major Changes

View File

@ -1,6 +1,6 @@
{
"name": "@hono/clerk-auth",
"version": "2.0.0",
"version": "2.0.1",
"description": "A third-party Clerk auth middleware for Hono",
"type": "module",
"main": "dist/index.cjs",
@ -13,6 +13,7 @@
"build": "tsup ./src/index.ts",
"prepack": "yarn build",
"publint": "attw --pack && publint",
"typecheck": "tsc -b tsconfig.json",
"test": "vitest"
},
"exports": {
@ -49,6 +50,7 @@
"publint": "^0.3.9",
"react": "^18.2.0",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vitest": "^3.0.8"
},
"engines": {

View File

@ -12,7 +12,7 @@ declare module 'hono' {
}
}
export const getAuth = (c: Context) => {
export const getAuth = (c: Context): ClerkAuth => {
return c.get('clerkAuth')
}

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": true,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"references": []
}

View File

@ -1,7 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"types": ["vitest/globals"]
}
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/clerk-auth",
"types": ["vitest/globals"]
},
"include": ["**/*.test.ts", "vitest.config.ts"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

Some files were not shown because too many files have changed in this diff Show More