Compare commits
No commits in common. "main" and "@hono/oauth-providers@0.8.1" have entirely different histories.
main
...
@hono/oaut
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/ajv-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/arktype-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/auth-js typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
name: ci-bun-compress
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- 'packages/bun-compress/**'
|
||||||
|
pull_request:
|
||||||
|
branches: ['*']
|
||||||
|
paths:
|
||||||
|
- 'packages/bun-compress/**'
|
||||||
|
|
||||||
|
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/bun-compress
|
||||||
|
- run: yarn workspace @hono/bun-compress build
|
||||||
|
- run: yarn workspace @hono/bun-compress publint
|
||||||
|
- run: yarn workspace @hono/bun-compress typecheck
|
||||||
|
- run: yarn eslint packages/bun-compress
|
||||||
|
- run: yarn test --coverage --project @hono/bun-compress
|
||||||
|
- uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
|
directory: ./coverage
|
||||||
|
flags: bun-compress
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
@ -22,7 +22,6 @@ jobs:
|
||||||
- run: yarn workspace @hono/bun-transpiler publint
|
- run: yarn workspace @hono/bun-transpiler publint
|
||||||
- run: yarn workspace @hono/bun-transpiler typecheck
|
- run: yarn workspace @hono/bun-transpiler typecheck
|
||||||
- run: yarn eslint packages/bun-transpiler
|
- 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
|
- run: yarn workspace @hono/bun-transpiler test --coverage --coverage-reporter lcov
|
||||||
- uses: codecov/codecov-action@v5
|
- uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/casbin typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/class-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/clerk-auth typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/cloudflare-access typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/conform-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/effect-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/esbuild-transpiler typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/event-emitter typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/firebase-auth typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/graphql-server typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/hello typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/medley-router typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/node-ws typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/oauth-providers typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/oidc-auth typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/otel typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/prometheus typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/qwik-city typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/react-compat typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/react-renderer typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/sentry typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/standard-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/swagger-editor typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/swagger-ui typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/trpc-server typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/tsyringe typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/typebox-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/typia-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -1,73 +0,0 @@
|
||||||
name: Sync robots.json
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# Runs every day at midnight
|
|
||||||
- cron: '15 0 */3 * *'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sync-and-pr:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
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: Check for changes
|
|
||||||
id: changes
|
|
||||||
run: |
|
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Generate changeset
|
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
|
||||||
run: |
|
|
||||||
# Use a static changeset filename to avoid duplicates
|
|
||||||
CHANGESET_FILE=".changeset/auto-sync-robots.md"
|
|
||||||
|
|
||||||
# Create the changeset file
|
|
||||||
cat << EOF > "$CHANGESET_FILE"
|
|
||||||
---
|
|
||||||
'@hono/ua-blocker': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
chore(ua-blocker): sync \`robots.json\` with upstream
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Format
|
|
||||||
run: yarn prettier --write . !packages packages/ua-blocker
|
|
||||||
|
|
||||||
- name: Create Pull Request if changes exist
|
|
||||||
if: steps.changes.outputs.has_changes == 'true'
|
|
||||||
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
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/valibot-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/zod-openapi typecheck
|
||||||
|
- 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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
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 workspace @hono/zod-validator typecheck
|
||||||
|
- 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 }}
|
|
@ -1,74 +0,0 @@
|
||||||
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 }}
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
name: codestyle
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: ['*']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20.x
|
||||||
|
- run: yarn
|
||||||
|
- run: yarn format
|
||||||
|
- run: yarn lint
|
|
@ -20,6 +20,3 @@ sandbox
|
||||||
# Claude Code local files
|
# Claude Code local files
|
||||||
CLAUDE.local.md
|
CLAUDE.local.md
|
||||||
settings.local.json
|
settings.local.json
|
||||||
|
|
||||||
# Code editor
|
|
||||||
.zed
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
.changeset
|
|
||||||
.vscode
|
|
||||||
.yarn
|
|
||||||
|
|
||||||
# Casbin
|
|
||||||
*.conf
|
|
||||||
*.csv
|
|
||||||
|
|
||||||
**/generated.ts
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
nmHoistingLimits: workspaces
|
|
||||||
|
|
||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-4.9.2.cjs
|
yarnPath: .yarn/releases/yarn-4.0.2.cjs
|
||||||
|
|
||||||
|
nmHoistingLimits: 'workspaces'
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"lint": "eslint 'packages/**/*.{ts,tsx}'",
|
"lint": "eslint 'packages/**/*.{ts,tsx}'",
|
||||||
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
|
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
|
||||||
"format": "prettier --check .",
|
"format": "prettier --check 'packages/**/*.{ts,tsx}'",
|
||||||
"format:fix": "prettier --write ."
|
"format:fix": "prettier --write 'packages/**/*.{ts,tsx}'"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
@ -44,5 +44,5 @@
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"vitest": "^3.0.8"
|
"vitest": "^3.0.8"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.9.2"
|
"packageManager": "yarn@4.0.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@arethetypeswrong/cli": "^0.17.4",
|
"@arethetypeswrong/cli": "^0.17.4",
|
||||||
"ajv": "^8.12.0",
|
"ajv": ">=8.12.0",
|
||||||
"publint": "^0.3.9",
|
"publint": "^0.3.9",
|
||||||
"tsup": "^8.4.0",
|
"tsup": "^8.4.0",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
# @hono/auth-js
|
# @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
|
## 1.0.16
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@hono/auth-js",
|
"name": "@hono/auth-js",
|
||||||
"version": "1.0.17",
|
"version": "1.0.16",
|
||||||
"description": "A third-party Auth js middleware for Hono",
|
"description": "A third-party Auth js middleware for Hono",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
@ -134,7 +134,7 @@ export async function fetchData<T = any>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useOnline(): boolean {
|
export function useOnline() {
|
||||||
const [isOnline, setIsOnline] = useState(
|
const [isOnline, setIsOnline] = useState(
|
||||||
typeof navigator !== 'undefined' ? navigator.onLine : false
|
typeof navigator !== 'undefined' ? navigator.onLine : false
|
||||||
)
|
)
|
||||||
|
@ -157,19 +157,11 @@ export function useOnline(): boolean {
|
||||||
return isOnline
|
return isOnline
|
||||||
}
|
}
|
||||||
|
|
||||||
export function now(): number {
|
export function now() {
|
||||||
return Math.floor(Date.now() / 1000)
|
return Math.floor(Date.now() / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsedUrl {
|
export function parseUrl(url?: string) {
|
||||||
origin: string
|
|
||||||
host: string
|
|
||||||
path: string
|
|
||||||
base: string
|
|
||||||
toString: () => string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parseUrl(url?: string): ParsedUrl {
|
|
||||||
const defaultUrl = 'http://localhost:3000/api/auth'
|
const defaultUrl = 'http://localhost:3000/api/auth'
|
||||||
const parsedUrl = new URL(url ? (url.startsWith('http') ? url : `https://${url}`) : defaultUrl)
|
const parsedUrl = new URL(url ? (url.startsWith('http') ? url : `https://${url}`) : defaultUrl)
|
||||||
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')
|
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')
|
||||||
|
|
|
@ -31,12 +31,12 @@ export interface AuthConfig extends Omit<AuthConfigCore, 'raw'> {}
|
||||||
|
|
||||||
export type ConfigHandler = (c: Context) => AuthConfig
|
export type ConfigHandler = (c: Context) => AuthConfig
|
||||||
|
|
||||||
export function setEnvDefaults(env: AuthEnv, config: AuthConfig): void {
|
export function setEnvDefaults(env: AuthEnv, config: AuthConfig) {
|
||||||
config.secret ??= env.AUTH_SECRET
|
config.secret ??= env.AUTH_SECRET
|
||||||
coreSetEnvDefaults(env, config)
|
coreSetEnvDefaults(env, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reqWithEnvUrl(req: Request, authUrl?: string): Request {
|
export function reqWithEnvUrl(req: Request, authUrl?: string) {
|
||||||
if (authUrl) {
|
if (authUrl) {
|
||||||
const reqUrlObj = new URL(req.url)
|
const reqUrlObj = new URL(req.url)
|
||||||
const authUrlObj = new URL(authUrl)
|
const authUrlObj = new URL(authUrl)
|
||||||
|
|
|
@ -65,11 +65,9 @@ class AuthConfigManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const authConfigManager: AuthConfigManager = AuthConfigManager.getInstance()
|
export const authConfigManager = AuthConfigManager.getInstance()
|
||||||
|
|
||||||
export const SessionContext: React.Context<SessionContextValue | undefined> = React.createContext<
|
export const SessionContext = React.createContext<SessionContextValue | undefined>(undefined)
|
||||||
SessionContextValue | undefined
|
|
||||||
>(undefined)
|
|
||||||
|
|
||||||
function useInitializeSession(hasInitialSession: boolean, initialSession: Session | null) {
|
function useInitializeSession(hasInitialSession: boolean, initialSession: Session | null) {
|
||||||
const authConfig = authConfigManager.getConfig()
|
const authConfig = authConfigManager.getConfig()
|
||||||
|
@ -150,7 +148,7 @@ function useRefetchInterval(
|
||||||
}, [refetchInterval, shouldRefetch])
|
}, [refetchInterval, shouldRefetch])
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSession(params?: GetSessionParams): Promise<Session | null> {
|
export async function getSession(params?: GetSessionParams) {
|
||||||
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
|
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
|
||||||
const session = await fetchData<Session>(
|
const session = await fetchData<Session>(
|
||||||
'session',
|
'session',
|
||||||
|
@ -165,7 +163,7 @@ export async function getSession(params?: GetSessionParams): Promise<Session | n
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCsrfToken(): Promise<string> {
|
export async function getCsrfToken() {
|
||||||
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
|
const { baseUrl, basePath, credentials } = authConfigManager.getConfig()
|
||||||
const response = await fetchData<{ csrfToken: string }>(
|
const response = await fetchData<{ csrfToken: string }>(
|
||||||
'csrf',
|
'csrf',
|
||||||
|
@ -179,7 +177,7 @@ export async function getCsrfToken(): Promise<string> {
|
||||||
return response?.csrfToken ?? ''
|
return response?.csrfToken ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SessionProvider(props: SessionProviderProps): React.JSX.Element {
|
export function SessionProvider(props: SessionProviderProps) {
|
||||||
if (!SessionContext) {
|
if (!SessionContext) {
|
||||||
throw new Error('React Context is unavailable in Server Components')
|
throw new Error('React Context is unavailable in Server Components')
|
||||||
}
|
}
|
||||||
|
@ -276,7 +274,7 @@ export function useSession<R extends boolean>(
|
||||||
|
|
||||||
type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>
|
type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>
|
||||||
|
|
||||||
export async function getProviders(): Promise<ProvidersType | null> {
|
export async function getProviders() {
|
||||||
return fetchData<ProvidersType>('providers', authConfigManager.getConfig(), logger)
|
return fetchData<ProvidersType>('providers', authConfigManager.getConfig(), logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,14 +395,10 @@ interface PopupLoginOptions extends Partial<Omit<WindowProps, 'url'>> {
|
||||||
callbackUrl?: string
|
callbackUrl?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LoginState extends AuthState {
|
|
||||||
popUpSignin: () => Promise<void>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useOauthPopupLogin = (
|
export const useOauthPopupLogin = (
|
||||||
provider: Parameters<typeof signIn>[0],
|
provider: Parameters<typeof signIn>[0],
|
||||||
options: PopupLoginOptions = {}
|
options: PopupLoginOptions = {}
|
||||||
): LoginState => {
|
) => {
|
||||||
const { width = 500, height = 500, title = 'Signin', onSuccess, callbackUrl = '/' } = options
|
const { width = 500, height = 500, title = 'Signin', onSuccess, callbackUrl = '/' } = options
|
||||||
|
|
||||||
const [externalWindow, setExternalWindow] = useState<Window | null>()
|
const [externalWindow, setExternalWindow] = useState<Window | null>()
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
|
||||||
"emitDeclarationOnly": true,
|
|
||||||
"isolatedDeclarations": true,
|
|
||||||
"jsx": "react"
|
"jsx": "react"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||||
"exclude": ["**/*.test.ts"],
|
|
||||||
"references": []
|
"references": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist/out-tsc/packages/auth-js",
|
"outDir": "../../dist/out-tsc/packages/auth-js",
|
||||||
|
"noEmit": true,
|
||||||
"jsx": "react"
|
"jsx": "react"
|
||||||
},
|
},
|
||||||
"include": ["**/*.test.ts", "vitest.config.ts"],
|
"include": ["**/*.test.ts", "vitest.config.ts"],
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true,
|
"isolatedDeclarations": true,
|
||||||
"types": ["node", "bun"]
|
"types": ["node", "bun"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*.ts"],
|
"include": ["./src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true,
|
"isolatedDeclarations": true,
|
||||||
"types": ["@cloudflare/workers-types"]
|
"types": ["@cloudflare/workers-types"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
|
||||||
"emitDeclarationOnly": true,
|
|
||||||
"isolatedDeclarations": true,
|
|
||||||
"types": ["@cloudflare/workers-types"]
|
"types": ["@cloudflare/workers-types"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
|
||||||
"exclude": ["**/*.test.ts"],
|
|
||||||
"references": []
|
"references": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist/out-tsc/packages/firebase-auth",
|
"outDir": "../../dist/out-tsc/packages/firebase-auth",
|
||||||
"types": ["@cloudflare/workers-types"]
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["**/*.test.ts", "firebase-tools.d.ts", "vitest.config.ts"],
|
"include": ["**/*.test.ts", "vitest.config.ts"],
|
||||||
"references": [
|
"references": [
|
||||||
{
|
{
|
||||||
"path": "./tsconfig.build.json"
|
"path": "./tsconfig.build.json"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# @hono/mcp
|
|
||||||
|
|
||||||
## 0.1.0
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- [#1178](https://github.com/honojs/middleware/pull/1178) [`1baa0b281dd4170f0003f9353a5f4c33fdcca610`](https://github.com/honojs/middleware/commit/1baa0b281dd4170f0003f9353a5f4c33fdcca610) Thanks [@MathurAditya724](https://github.com/MathurAditya724)! - init release
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Hono MCP (Model Context Protocol)
|
|
||||||
|
|
||||||
Connect Hono with a Model Context Protocol (MCP) server over HTTP Streaming Transport.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
||||||
import { StreamableHTTPTransport } from '@hono/mcp'
|
|
||||||
import { Hono } from 'hono'
|
|
||||||
|
|
||||||
const app = new Hono()
|
|
||||||
|
|
||||||
// Your MCP server implementation
|
|
||||||
const mcpServer = new McpServer({
|
|
||||||
name: 'my-mcp-server',
|
|
||||||
version: '1.0.0',
|
|
||||||
})
|
|
||||||
|
|
||||||
app.all('/mcp', async (c) => {
|
|
||||||
const transport = new StreamableHTTPTransport()
|
|
||||||
await mcpServer.connect(transport)
|
|
||||||
return transport.handleRequest(c)
|
|
||||||
})
|
|
||||||
|
|
||||||
export default app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Author
|
|
||||||
|
|
||||||
Aditya Mathur <https://github.com/mathuraditya724>
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
|
@ -1,52 +0,0 @@
|
||||||
{
|
|
||||||
"name": "@hono/mcp",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"description": "MCP Middleware for Hono",
|
|
||||||
"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": "vitest"
|
|
||||||
},
|
|
||||||
"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/mcp"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/honojs/middleware",
|
|
||||||
"peerDependencies": {
|
|
||||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
||||||
"hono": "*"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@arethetypeswrong/cli": "^0.17.4",
|
|
||||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
||||||
"publint": "^0.3.9",
|
|
||||||
"tsup": "^8.4.0",
|
|
||||||
"typescript": "^5.8.2",
|
|
||||||
"vitest": "^3.0.8",
|
|
||||||
"zod": "^3.25.34"
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,613 +0,0 @@
|
||||||
/**
|
|
||||||
* @module
|
|
||||||
* MCP HTTP Streaming Helper for Hono.
|
|
||||||
*/
|
|
||||||
import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js'
|
|
||||||
import type {
|
|
||||||
EventStore,
|
|
||||||
StreamableHTTPServerTransportOptions,
|
|
||||||
} from '@modelcontextprotocol/sdk/server/streamableHttp.js'
|
|
||||||
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'
|
|
||||||
import {
|
|
||||||
isInitializeRequest,
|
|
||||||
isJSONRPCError,
|
|
||||||
isJSONRPCRequest,
|
|
||||||
isJSONRPCResponse,
|
|
||||||
JSONRPCMessageSchema,
|
|
||||||
} from '@modelcontextprotocol/sdk/types.js'
|
|
||||||
import type { JSONRPCMessage, RequestId } from '@modelcontextprotocol/sdk/types.js'
|
|
||||||
import type { Context } from 'hono'
|
|
||||||
import { HTTPException } from 'hono/http-exception'
|
|
||||||
import type { SSEStreamingApi } from 'hono/streaming'
|
|
||||||
import { streamSSE } from './streaming'
|
|
||||||
|
|
||||||
export class StreamableHTTPTransport implements Transport {
|
|
||||||
#started = false
|
|
||||||
#initialized = false
|
|
||||||
#onsessioninitialized?: (sessionId: string) => void
|
|
||||||
#sessionIdGenerator?: () => string
|
|
||||||
#eventStore?: EventStore
|
|
||||||
#enableJsonResponse = false
|
|
||||||
#standaloneSseStreamId = '_GET_stream'
|
|
||||||
#streamMapping = new Map<
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
ctx: {
|
|
||||||
header: (name: string, value: string) => void
|
|
||||||
json: (data: unknown) => void
|
|
||||||
}
|
|
||||||
stream?: SSEStreamingApi
|
|
||||||
}
|
|
||||||
>()
|
|
||||||
#requestToStreamMapping = new Map<RequestId, string>()
|
|
||||||
#requestResponseMap = new Map<RequestId, JSONRPCMessage>()
|
|
||||||
|
|
||||||
sessionId?: string | undefined
|
|
||||||
onclose?: () => void
|
|
||||||
onerror?: (error: Error) => void
|
|
||||||
onmessage?: (message: JSONRPCMessage, extra?: { authInfo?: AuthInfo }) => void
|
|
||||||
|
|
||||||
constructor(options?: StreamableHTTPServerTransportOptions) {
|
|
||||||
this.#sessionIdGenerator = options?.sessionIdGenerator
|
|
||||||
this.#enableJsonResponse = options?.enableJsonResponse ?? false
|
|
||||||
this.#eventStore = options?.eventStore
|
|
||||||
this.#onsessioninitialized = options?.onsessioninitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the transport. This is required by the Transport interface but is a no-op
|
|
||||||
* for the Streamable HTTP transport as connections are managed per-request.
|
|
||||||
*/
|
|
||||||
async start(): Promise<void> {
|
|
||||||
if (this.#started) {
|
|
||||||
throw new Error('Transport already started')
|
|
||||||
}
|
|
||||||
this.#started = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles an incoming HTTP request, whether GET or POST
|
|
||||||
*/
|
|
||||||
async handleRequest(ctx: Context, parsedBody?: unknown): Promise<Response | undefined> {
|
|
||||||
switch (ctx.req.method) {
|
|
||||||
case 'GET':
|
|
||||||
return this.handleGetRequest(ctx)
|
|
||||||
case 'POST':
|
|
||||||
return this.handlePostRequest(ctx, parsedBody)
|
|
||||||
case 'DELETE':
|
|
||||||
return this.handleDeleteRequest(ctx)
|
|
||||||
default:
|
|
||||||
return this.handleUnsupportedRequest(ctx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles GET requests for SSE stream
|
|
||||||
*/
|
|
||||||
private async handleGetRequest(ctx: Context) {
|
|
||||||
try {
|
|
||||||
// The client MUST include an Accept header, listing text/event-stream as a supported content type.
|
|
||||||
const acceptHeader = ctx.req.header('Accept')
|
|
||||||
if (!acceptHeader?.includes('text/event-stream')) {
|
|
||||||
throw new HTTPException(406, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Not Acceptable: Client must accept text/event-stream',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// If an Mcp-Session-Id is returned by the server during initialization,
|
|
||||||
// clients using the Streamable HTTP transport MUST include it
|
|
||||||
// in the Mcp-Session-Id header on all of their subsequent HTTP requests.
|
|
||||||
this.validateSession(ctx)
|
|
||||||
|
|
||||||
// After initialization, always include the session ID if we have one
|
|
||||||
if (this.sessionId !== undefined) {
|
|
||||||
ctx.header('mcp-session-id', this.sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
let streamId: string | ((stream: SSEStreamingApi) => Promise<string>) =
|
|
||||||
this.#standaloneSseStreamId
|
|
||||||
|
|
||||||
// Handle resumability: check for Last-Event-ID header
|
|
||||||
if (this.#eventStore) {
|
|
||||||
const lastEventId = ctx.req.header('last-event-id')
|
|
||||||
if (lastEventId) {
|
|
||||||
streamId = (stream) =>
|
|
||||||
this.#eventStore!.replayEventsAfter(lastEventId, {
|
|
||||||
send: async (eventId: string, message: JSONRPCMessage) => {
|
|
||||||
try {
|
|
||||||
await stream.writeSSE({
|
|
||||||
id: eventId,
|
|
||||||
event: 'message',
|
|
||||||
data: JSON.stringify(message),
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
this.onerror?.(new Error('Failed replay events'))
|
|
||||||
throw new HTTPException(500, {
|
|
||||||
message: 'Failed replay events',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there's already an active standalone SSE stream for this session
|
|
||||||
if (typeof streamId === 'string' && this.#streamMapping.get(streamId) !== undefined) {
|
|
||||||
// Only one GET SSE stream is allowed per session
|
|
||||||
throw new HTTPException(409, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Conflict: Only one SSE stream is allowed per session',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return streamSSE(ctx, async (stream) => {
|
|
||||||
const resolvedStreamId = typeof streamId === 'string' ? streamId : await streamId(stream)
|
|
||||||
|
|
||||||
// Assign the response to the standalone SSE stream
|
|
||||||
this.#streamMapping.set(resolvedStreamId, {
|
|
||||||
ctx,
|
|
||||||
stream,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Keep connection alive
|
|
||||||
const keepAlive = setInterval(() => {
|
|
||||||
if (!stream.closed) {
|
|
||||||
stream.writeSSE({ data: '', event: 'ping' }).catch(() => clearInterval(keepAlive))
|
|
||||||
}
|
|
||||||
}, 30000)
|
|
||||||
|
|
||||||
// Set up close handler for client disconnects
|
|
||||||
stream.onAbort(() => {
|
|
||||||
this.#streamMapping.delete(resolvedStreamId)
|
|
||||||
clearInterval(keepAlive)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof HTTPException) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onerror?.(error as Error)
|
|
||||||
|
|
||||||
// return JSON-RPC formatted error
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32700,
|
|
||||||
message: 'Parse error',
|
|
||||||
data: String(error),
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles POST requests containing JSON-RPC messages
|
|
||||||
*/
|
|
||||||
private async handlePostRequest(ctx: Context, parsedBody?: unknown) {
|
|
||||||
try {
|
|
||||||
// Validate the Accept header
|
|
||||||
const acceptHeader = ctx.req.header('Accept')
|
|
||||||
// The client MUST include an Accept header, listing both application/json and text/event-stream as supported content types.
|
|
||||||
if (
|
|
||||||
!acceptHeader?.includes('application/json') ||
|
|
||||||
!acceptHeader.includes('text/event-stream')
|
|
||||||
) {
|
|
||||||
throw new HTTPException(406, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message:
|
|
||||||
'Not Acceptable: Client must accept both application/json and text/event-stream',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const ct = ctx.req.header('Content-Type')
|
|
||||||
if (!ct?.includes('application/json')) {
|
|
||||||
throw new HTTPException(415, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Unsupported Media Type: Content-Type must be application/json',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const authInfo: AuthInfo | undefined = ctx.get('auth')
|
|
||||||
|
|
||||||
let rawMessage = parsedBody
|
|
||||||
if (rawMessage === undefined) {
|
|
||||||
rawMessage = await ctx.req.json()
|
|
||||||
}
|
|
||||||
|
|
||||||
let messages: JSONRPCMessage[]
|
|
||||||
|
|
||||||
// handle batch and single messages
|
|
||||||
if (Array.isArray(rawMessage)) {
|
|
||||||
messages = rawMessage.map((msg) => JSONRPCMessageSchema.parse(msg))
|
|
||||||
} else {
|
|
||||||
messages = [JSONRPCMessageSchema.parse(rawMessage)]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is an initialization request
|
|
||||||
// https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle/
|
|
||||||
const isInitializationRequest = messages.some(isInitializeRequest)
|
|
||||||
if (isInitializationRequest) {
|
|
||||||
// If it's a server with session management and the session ID is already set we should reject the request
|
|
||||||
// to avoid re-initialization.
|
|
||||||
if (this.#initialized && this.sessionId !== undefined) {
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32600,
|
|
||||||
message: 'Invalid Request: Server already initialized',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messages.length > 1) {
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32600,
|
|
||||||
message: 'Invalid Request: Only one initialization request is allowed',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.sessionId = this.#sessionIdGenerator?.()
|
|
||||||
this.#initialized = true
|
|
||||||
|
|
||||||
// If we have a session ID and an onsessioninitialized handler, call it immediately
|
|
||||||
// This is needed in cases where the server needs to keep track of multiple sessions
|
|
||||||
if (this.sessionId && this.#onsessioninitialized) {
|
|
||||||
this.#onsessioninitialized(this.sessionId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If an Mcp-Session-Id is returned by the server during initialization,
|
|
||||||
// clients using the Streamable HTTP transport MUST include it
|
|
||||||
// in the Mcp-Session-Id header on all of their subsequent HTTP requests.
|
|
||||||
if (!isInitializationRequest) {
|
|
||||||
this.validateSession(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if it contains requests
|
|
||||||
const hasRequests = messages.some(isJSONRPCRequest)
|
|
||||||
|
|
||||||
if (!hasRequests) {
|
|
||||||
// handle each message
|
|
||||||
for (const message of messages) {
|
|
||||||
this.onmessage?.(message, { authInfo })
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it only contains notifications or responses, return 202
|
|
||||||
return ctx.body(null, 202)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasRequests) {
|
|
||||||
// The default behavior is to use SSE streaming
|
|
||||||
// but in some cases server will return JSON responses
|
|
||||||
const streamId = crypto.randomUUID()
|
|
||||||
|
|
||||||
if (!this.#enableJsonResponse && this.sessionId !== undefined) {
|
|
||||||
ctx.header('mcp-session-id', this.sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.#enableJsonResponse) {
|
|
||||||
// Store the response for this request to send messages back through this connection
|
|
||||||
// We need to track by request ID to maintain the connection
|
|
||||||
const result = await new Promise<any>((resolve) => {
|
|
||||||
for (const message of messages) {
|
|
||||||
if (isJSONRPCRequest(message)) {
|
|
||||||
this.#streamMapping.set(streamId, {
|
|
||||||
ctx: {
|
|
||||||
header: ctx.header,
|
|
||||||
json: resolve,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
this.#requestToStreamMapping.set(message.id, streamId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle each message
|
|
||||||
for (const message of messages) {
|
|
||||||
this.onmessage?.(message, { authInfo })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return ctx.json(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
return streamSSE(ctx, async (stream) => {
|
|
||||||
// Store the response for this request to send messages back through this connection
|
|
||||||
// We need to track by request ID to maintain the connection
|
|
||||||
for (const message of messages) {
|
|
||||||
if (isJSONRPCRequest(message)) {
|
|
||||||
this.#streamMapping.set(streamId, {
|
|
||||||
ctx,
|
|
||||||
stream,
|
|
||||||
})
|
|
||||||
this.#requestToStreamMapping.set(message.id, streamId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up close handler for client disconnects
|
|
||||||
stream.onAbort(() => {
|
|
||||||
this.#streamMapping.delete(streamId)
|
|
||||||
})
|
|
||||||
|
|
||||||
// handle each message
|
|
||||||
for (const message of messages) {
|
|
||||||
this.onmessage?.(message, { authInfo })
|
|
||||||
}
|
|
||||||
// The server SHOULD NOT close the SSE stream before sending all JSON-RPC responses
|
|
||||||
// This will be handled by the send() method when responses are ready
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof HTTPException) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onerror?.(error as Error)
|
|
||||||
|
|
||||||
// return JSON-RPC formatted error
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32700,
|
|
||||||
message: 'Parse error',
|
|
||||||
data: String(error),
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles DELETE requests to terminate sessions
|
|
||||||
*/
|
|
||||||
private async handleDeleteRequest(ctx: Context) {
|
|
||||||
this.validateSession(ctx)
|
|
||||||
|
|
||||||
await this.close()
|
|
||||||
|
|
||||||
return ctx.body(null, 200)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
||||||
*/
|
|
||||||
private handleUnsupportedRequest(ctx: Context) {
|
|
||||||
return ctx.json(
|
|
||||||
{
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Method not allowed.',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
status: 405,
|
|
||||||
headers: {
|
|
||||||
Allow: 'GET, POST, DELETE',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates session ID for non-initialization requests
|
|
||||||
* Returns true if the session is valid, false otherwise
|
|
||||||
*/
|
|
||||||
private validateSession(ctx: Context): boolean {
|
|
||||||
if (this.#sessionIdGenerator === undefined) {
|
|
||||||
// If the sessionIdGenerator ID is not set, the session management is disabled
|
|
||||||
// and we don't need to validate the session ID
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (!this.#initialized) {
|
|
||||||
// If the server has not been initialized yet, reject all requests
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Bad Request: Server not initialized',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const sessionId = ctx.req.header('mcp-session-id')
|
|
||||||
|
|
||||||
if (!sessionId) {
|
|
||||||
// Non-initialization requests without a session ID should return 400 Bad Request
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Bad Request: Mcp-Session-Id header is required',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(sessionId)) {
|
|
||||||
throw new HTTPException(400, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32000,
|
|
||||||
message: 'Bad Request: Mcp-Session-Id header must be a single value',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sessionId !== this.sessionId) {
|
|
||||||
// Reject requests with invalid session ID with 404 Not Found
|
|
||||||
throw new HTTPException(404, {
|
|
||||||
res: Response.json({
|
|
||||||
jsonrpc: '2.0',
|
|
||||||
error: {
|
|
||||||
code: -32001,
|
|
||||||
message: 'Session not found',
|
|
||||||
},
|
|
||||||
id: null,
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
async close(): Promise<void> {
|
|
||||||
// Close all SSE connections
|
|
||||||
|
|
||||||
for (const { stream } of this.#streamMapping.values()) {
|
|
||||||
stream?.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#streamMapping.clear()
|
|
||||||
|
|
||||||
// Clear any pending responses
|
|
||||||
this.#requestResponseMap.clear()
|
|
||||||
this.onclose?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
async send(message: JSONRPCMessage, options?: { relatedRequestId?: RequestId }): Promise<void> {
|
|
||||||
let requestId = options?.relatedRequestId
|
|
||||||
if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
|
|
||||||
// If the message is a response, use the request ID from the message
|
|
||||||
requestId = message.id
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this message should be sent on the standalone SSE stream (no request ID)
|
|
||||||
// Ignore notifications from tools (which have relatedRequestId set)
|
|
||||||
// Those will be sent via dedicated response SSE streams
|
|
||||||
if (requestId === undefined) {
|
|
||||||
// For standalone SSE streams, we can only send requests and notifications
|
|
||||||
if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
|
|
||||||
throw new Error(
|
|
||||||
'Cannot send a response on a standalone SSE stream unless resuming a previous client request'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
const standaloneSse = this.#streamMapping.get(this.#standaloneSseStreamId)
|
|
||||||
|
|
||||||
if (standaloneSse === undefined) {
|
|
||||||
// The spec says the server MAY send messages on the stream, so it's ok to discard if no stream
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate and store event ID if event store is provided
|
|
||||||
let eventId: string | undefined
|
|
||||||
if (this.#eventStore) {
|
|
||||||
// Stores the event and gets the generated event ID
|
|
||||||
eventId = await this.#eventStore.storeEvent(this.#standaloneSseStreamId, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the message to the standalone SSE stream
|
|
||||||
return standaloneSse.stream?.writeSSE({
|
|
||||||
id: eventId,
|
|
||||||
event: 'message',
|
|
||||||
data: JSON.stringify(message),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the response for this request
|
|
||||||
const streamId = this.#requestToStreamMapping.get(requestId)
|
|
||||||
const response = this.#streamMapping.get(streamId!)
|
|
||||||
if (!streamId) {
|
|
||||||
throw new Error(`No connection established for request ID: ${String(requestId)}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.#enableJsonResponse) {
|
|
||||||
// For SSE responses, generate event ID if event store is provided
|
|
||||||
let eventId: string | undefined
|
|
||||||
|
|
||||||
if (this.#eventStore) {
|
|
||||||
eventId = await this.#eventStore.storeEvent(streamId, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
// Write the event to the response stream
|
|
||||||
await response.stream?.writeSSE({
|
|
||||||
id: eventId,
|
|
||||||
event: 'message',
|
|
||||||
data: JSON.stringify(message),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
|
|
||||||
this.#requestResponseMap.set(requestId, message)
|
|
||||||
const relatedIds = Array.from(this.#requestToStreamMapping.entries())
|
|
||||||
.filter(([, streamId]) => this.#streamMapping.get(streamId) === response)
|
|
||||||
.map(([id]) => id)
|
|
||||||
|
|
||||||
// Check if we have responses for all requests using this connection
|
|
||||||
const allResponsesReady = relatedIds.every((id) => this.#requestResponseMap.has(id))
|
|
||||||
|
|
||||||
if (allResponsesReady) {
|
|
||||||
if (!response) {
|
|
||||||
throw new Error(`No connection established for request ID: ${String(requestId)}`)
|
|
||||||
}
|
|
||||||
if (this.#enableJsonResponse) {
|
|
||||||
// All responses ready, send as JSON
|
|
||||||
if (this.sessionId !== undefined) {
|
|
||||||
response.ctx.header('mcp-session-id', this.sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
const responses = relatedIds.map((id) => this.#requestResponseMap.get(id)!)
|
|
||||||
|
|
||||||
response.ctx.json(responses.length === 1 ? responses[0] : responses)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
response.stream?.close()
|
|
||||||
}
|
|
||||||
// Clean up
|
|
||||||
for (const id of relatedIds) {
|
|
||||||
this.#requestResponseMap.delete(id)
|
|
||||||
this.#requestToStreamMapping.delete(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
import type { Context } from 'hono'
|
|
||||||
import { SSEStreamingApi } from 'hono/streaming'
|
|
||||||
|
|
||||||
let isOldBunVersion = (): boolean => {
|
|
||||||
// @ts-expect-error @types/bun is not installed
|
|
||||||
const version: string = typeof Bun !== 'undefined' ? Bun.version : undefined
|
|
||||||
if (version === undefined) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const result = version.startsWith('1.1') || version.startsWith('1.0') || version.startsWith('0.')
|
|
||||||
// Avoid running this check on every call
|
|
||||||
isOldBunVersion = () => result
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
const run = async (
|
|
||||||
stream: SSEStreamingApi,
|
|
||||||
cb: (stream: SSEStreamingApi) => Promise<void>,
|
|
||||||
onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>
|
|
||||||
): Promise<void> => {
|
|
||||||
try {
|
|
||||||
await cb(stream)
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Error && onError) {
|
|
||||||
await onError(e, stream)
|
|
||||||
|
|
||||||
await stream.writeSSE({
|
|
||||||
event: 'error',
|
|
||||||
data: e.message,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
console.error(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const contextStash: WeakMap<ReadableStream, Context> = new WeakMap<ReadableStream, Context>()
|
|
||||||
|
|
||||||
export const streamSSE = (
|
|
||||||
c: Context,
|
|
||||||
cb: (stream: SSEStreamingApi) => Promise<void>,
|
|
||||||
onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>
|
|
||||||
): Response => {
|
|
||||||
const { readable, writable } = new TransformStream()
|
|
||||||
const stream = new SSEStreamingApi(writable, readable)
|
|
||||||
|
|
||||||
// Until Bun v1.1.27, Bun didn't call cancel() on the ReadableStream for Response objects from Bun.serve()
|
|
||||||
if (isOldBunVersion()) {
|
|
||||||
c.req.raw.signal.addEventListener('abort', () => {
|
|
||||||
if (!stream.closed) {
|
|
||||||
stream.abort()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// in bun, `c` is destroyed when the request is returned, so hold it until the end of streaming
|
|
||||||
contextStash.set(stream.responseReadable, c)
|
|
||||||
|
|
||||||
c.header('Transfer-Encoding', 'chunked')
|
|
||||||
c.header('Content-Type', 'text/event-stream')
|
|
||||||
c.header('Cache-Control', 'no-cache')
|
|
||||||
c.header('Connection', 'keep-alive')
|
|
||||||
|
|
||||||
run(stream, cb, onError)
|
|
||||||
|
|
||||||
return c.newResponse(stream.responseReadable)
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"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": []
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../../tsconfig.base.json",
|
|
||||||
"files": [],
|
|
||||||
"include": [],
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.build.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.spec.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { defineProject } from 'vitest/config'
|
|
||||||
|
|
||||||
export default defineProject({
|
|
||||||
test: {
|
|
||||||
globals: true,
|
|
||||||
},
|
|
||||||
})
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true,
|
"isolatedDeclarations": true,
|
||||||
"types": ["node", "ws"]
|
"types": ["node", "ws"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
"references": [
|
"references": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
|
||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": false,
|
||||||
"isolatedDeclarations": true
|
"isolatedDeclarations": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts"],
|
"include": ["src/**/*.ts"],
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue