bluera-knowledge 0.9.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/commit.md +37 -0
- package/.claude/hooks/post-edit-check.sh +41 -0
- package/.claude/settings.local.json.example +40 -0
- package/.claude/skills/atomic-commits/SKILL.md +53 -0
- package/.claude-plugin/plugin.json +13 -0
- package/.editorconfig +15 -0
- package/.github/workflows/auto-release.yml +59 -0
- package/.github/workflows/ci.yml +142 -0
- package/.github/workflows/release.yml +66 -0
- package/.github/workflows/update-marketplace.yml +96 -0
- package/.husky/pre-commit +47 -0
- package/.husky/pre-push +29 -0
- package/.versionrc.json +28 -0
- package/CHANGELOG.md +410 -0
- package/CLAUDE.md +109 -0
- package/LICENSE +21 -0
- package/NOTICE +47 -0
- package/README.md +1546 -0
- package/SECURITY.md +65 -0
- package/bun.lock +1758 -0
- package/commands/add-folder.md +48 -0
- package/commands/add-repo.md +50 -0
- package/commands/cancel.md +63 -0
- package/commands/check-status.md +78 -0
- package/commands/crawl.md +51 -0
- package/commands/index.md +48 -0
- package/commands/remove-store.md +52 -0
- package/commands/search.md +79 -0
- package/commands/search.sh +63 -0
- package/commands/stores.md +54 -0
- package/commands/suggest.md +82 -0
- package/dist/chunk-5QMHZUC4.js +3617 -0
- package/dist/chunk-5QMHZUC4.js.map +1 -0
- package/dist/chunk-BICFAWMN.js +656 -0
- package/dist/chunk-BICFAWMN.js.map +1 -0
- package/dist/chunk-J7J6LXOJ.js +958 -0
- package/dist/chunk-J7J6LXOJ.js.map +1 -0
- package/dist/chunk-L2YVNC63.js +59 -0
- package/dist/chunk-L2YVNC63.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1429 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +11 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/watch.service-YAIKKDCF.js +7 -0
- package/dist/watch.service-YAIKKDCF.js.map +1 -0
- package/dist/workers/background-worker-cli.d.ts +1 -0
- package/dist/workers/background-worker-cli.js +310 -0
- package/dist/workers/background-worker-cli.js.map +1 -0
- package/docs/plans/2024-12-17-ai-search-quality-implementation.md +752 -0
- package/docs/plans/2024-12-17-ai-search-quality-testing-design.md +201 -0
- package/docs/plans/2025-12-16-bluera-knowledge-cli.md +2951 -0
- package/docs/plans/2025-12-16-phase2-features.md +1518 -0
- package/docs/plans/2025-12-17-hil-implementation.md +926 -0
- package/docs/plans/2025-12-17-hil-quality-testing.md +224 -0
- package/docs/plans/2025-12-17-search-quality-phase1-implementation.md +1416 -0
- package/docs/plans/2025-12-17-search-quality-testing-v2-design.md +212 -0
- package/docs/plans/2025-12-28-ai-agent-optimization.md +1630 -0
- package/eslint-rules/require-skip-comment.js +81 -0
- package/eslint.config.js +61 -0
- package/hooks/check-dependencies.sh +110 -0
- package/hooks/format-search-results.py +132 -0
- package/hooks/hooks.json +27 -0
- package/hooks/job-status-hook.sh +51 -0
- package/knip.json +43 -0
- package/mcp.plugin.json +12 -0
- package/package.json +103 -0
- package/python/crawl_worker.py +275 -0
- package/python/requirements.txt +2 -0
- package/scripts/readme-version-updater.cjs +18 -0
- package/skills/advanced-workflows/SKILL.md +273 -0
- package/skills/atomic-commits/SKILL.md +77 -0
- package/skills/knowledge-search/SKILL.md +54 -0
- package/skills/search-optimization/SKILL.md +396 -0
- package/skills/store-lifecycle/SKILL.md +470 -0
- package/skills/when-to-query/SKILL.md +66 -0
- package/src/analysis/ast-parser.test.ts +423 -0
- package/src/analysis/ast-parser.ts +192 -0
- package/src/analysis/code-graph.test.ts +698 -0
- package/src/analysis/code-graph.ts +245 -0
- package/src/analysis/dependency-usage-analyzer.test.ts +799 -0
- package/src/analysis/dependency-usage-analyzer.ts +405 -0
- package/src/analysis/go-ast-parser.test.ts +531 -0
- package/src/analysis/go-ast-parser.ts +478 -0
- package/src/analysis/parser-factory.test.ts +132 -0
- package/src/analysis/parser-factory.ts +44 -0
- package/src/analysis/python-ast-parser.test.ts +210 -0
- package/src/analysis/python-ast-parser.ts +34 -0
- package/src/analysis/repo-url-resolver.test.ts +533 -0
- package/src/analysis/repo-url-resolver.ts +233 -0
- package/src/analysis/rust-ast-parser.test.ts +568 -0
- package/src/analysis/rust-ast-parser.ts +477 -0
- package/src/analysis/tree-sitter-parser.test.ts +297 -0
- package/src/analysis/tree-sitter-parser.ts +223 -0
- package/src/cli/commands/crawl.test.ts +942 -0
- package/src/cli/commands/crawl.ts +141 -0
- package/src/cli/commands/index-cmd.test.ts +722 -0
- package/src/cli/commands/index-cmd.ts +105 -0
- package/src/cli/commands/mcp.test.ts +218 -0
- package/src/cli/commands/mcp.ts +18 -0
- package/src/cli/commands/plugin-api.test.ts +313 -0
- package/src/cli/commands/plugin-api.ts +45 -0
- package/src/cli/commands/search.test.ts +911 -0
- package/src/cli/commands/search.ts +113 -0
- package/src/cli/commands/serve.test.ts +329 -0
- package/src/cli/commands/serve.ts +28 -0
- package/src/cli/commands/setup.test.ts +820 -0
- package/src/cli/commands/setup.ts +153 -0
- package/src/cli/commands/store.test.ts +1003 -0
- package/src/cli/commands/store.ts +167 -0
- package/src/cli/index.ts +7 -0
- package/src/cli/program.ts +59 -0
- package/src/crawl/article-converter.test.ts +604 -0
- package/src/crawl/article-converter.ts +98 -0
- package/src/crawl/bridge.test.ts +674 -0
- package/src/crawl/bridge.ts +236 -0
- package/src/crawl/claude-client.test.ts +663 -0
- package/src/crawl/claude-client.ts +234 -0
- package/src/crawl/intelligent-crawler.test.ts +931 -0
- package/src/crawl/intelligent-crawler.ts +428 -0
- package/src/crawl/markdown-utils.test.ts +703 -0
- package/src/crawl/markdown-utils.ts +228 -0
- package/src/crawl/schemas.ts +114 -0
- package/src/db/embeddings.test.ts +63 -0
- package/src/db/embeddings.ts +69 -0
- package/src/db/index.ts +2 -0
- package/src/db/lance.test.ts +390 -0
- package/src/db/lance.ts +164 -0
- package/src/defaults/repos.ts +67 -0
- package/src/index.ts +107 -0
- package/src/mcp/cache.test.ts +202 -0
- package/src/mcp/cache.ts +103 -0
- package/src/mcp/commands/index.ts +20 -0
- package/src/mcp/commands/job.commands.ts +54 -0
- package/src/mcp/commands/meta.commands.ts +54 -0
- package/src/mcp/commands/registry.ts +183 -0
- package/src/mcp/commands/store.commands.ts +75 -0
- package/src/mcp/handlers/execute.handler.test.ts +179 -0
- package/src/mcp/handlers/execute.handler.ts +24 -0
- package/src/mcp/handlers/index.ts +43 -0
- package/src/mcp/handlers/job.handler.test.ts +189 -0
- package/src/mcp/handlers/job.handler.ts +116 -0
- package/src/mcp/handlers/search.handler.test.ts +334 -0
- package/src/mcp/handlers/search.handler.ts +209 -0
- package/src/mcp/handlers/store.handler.test.ts +415 -0
- package/src/mcp/handlers/store.handler.ts +295 -0
- package/src/mcp/schemas/index.test.ts +315 -0
- package/src/mcp/schemas/index.ts +138 -0
- package/src/mcp/server.test.ts +36 -0
- package/src/mcp/server.ts +162 -0
- package/src/mcp/types.ts +41 -0
- package/src/plugin/commands.test.ts +789 -0
- package/src/plugin/commands.ts +257 -0
- package/src/plugin/dependency-analyzer.test.ts +380 -0
- package/src/plugin/dependency-analyzer.ts +147 -0
- package/src/plugin/git-clone.test.ts +332 -0
- package/src/plugin/git-clone.ts +57 -0
- package/src/server/app.test.ts +752 -0
- package/src/server/app.ts +119 -0
- package/src/server/index.test.ts +477 -0
- package/src/server/index.ts +1 -0
- package/src/services/chunking.service.test.ts +363 -0
- package/src/services/chunking.service.ts +350 -0
- package/src/services/code-graph.service.test.ts +304 -0
- package/src/services/code-graph.service.ts +302 -0
- package/src/services/code-unit.service.test.ts +596 -0
- package/src/services/code-unit.service.ts +115 -0
- package/src/services/config.service.test.ts +127 -0
- package/src/services/config.service.ts +69 -0
- package/src/services/index.service.test.ts +1002 -0
- package/src/services/index.service.ts +266 -0
- package/src/services/index.ts +75 -0
- package/src/services/job.service.test.ts +418 -0
- package/src/services/job.service.ts +246 -0
- package/src/services/project-root.service.test.ts +506 -0
- package/src/services/project-root.service.ts +112 -0
- package/src/services/search.service.test.ts +1105 -0
- package/src/services/search.service.ts +892 -0
- package/src/services/services.test.ts +38 -0
- package/src/services/snippet.service.test.ts +205 -0
- package/src/services/snippet.service.ts +166 -0
- package/src/services/store.service.test.ts +474 -0
- package/src/services/store.service.ts +225 -0
- package/src/services/watch.service.test.ts +553 -0
- package/src/services/watch.service.ts +71 -0
- package/src/types/brands.test.ts +45 -0
- package/src/types/brands.ts +32 -0
- package/src/types/config.ts +79 -0
- package/src/types/document.ts +30 -0
- package/src/types/index.ts +66 -0
- package/src/types/job.ts +46 -0
- package/src/types/progress.ts +9 -0
- package/src/types/result.test.ts +44 -0
- package/src/types/result.ts +41 -0
- package/src/types/search.ts +95 -0
- package/src/types/store.test.ts +69 -0
- package/src/types/store.ts +47 -0
- package/src/utils/type-guards.test.ts +346 -0
- package/src/utils/type-guards.ts +61 -0
- package/src/workers/background-worker-cli.ts +105 -0
- package/src/workers/background-worker.test.ts +178 -0
- package/src/workers/background-worker.ts +294 -0
- package/src/workers/spawn-worker.test.ts +128 -0
- package/src/workers/spawn-worker.ts +49 -0
- package/tests/analysis/ast-parser.test.ts +98 -0
- package/tests/analysis/code-graph.test.ts +60 -0
- package/tests/fixtures/README.md +114 -0
- package/tests/fixtures/code-snippets/api/error-handling.ts +267 -0
- package/tests/fixtures/code-snippets/api/rest-controller.ts +303 -0
- package/tests/fixtures/code-snippets/auth/jwt-auth.ts +213 -0
- package/tests/fixtures/code-snippets/auth/oauth-flow.ts +245 -0
- package/tests/fixtures/code-snippets/database/repository-pattern.ts +272 -0
- package/tests/fixtures/corpus/VERSION.md +25 -0
- package/tests/fixtures/corpus/articles/jwt-authentication.md +97 -0
- package/tests/fixtures/corpus/articles/react-hooks-patterns.md +127 -0
- package/tests/fixtures/corpus/articles/typescript-generics.md +111 -0
- package/tests/fixtures/corpus/documentation/express-middleware.md +71 -0
- package/tests/fixtures/corpus/documentation/express-routing.md +83 -0
- package/tests/fixtures/corpus/documentation/node-streams.md +78 -0
- package/tests/fixtures/corpus/oss-repos/express/History.md +3871 -0
- package/tests/fixtures/corpus/oss-repos/express/LICENSE +24 -0
- package/tests/fixtures/corpus/oss-repos/express/Readme.md +276 -0
- package/tests/fixtures/corpus/oss-repos/express/SECURITY.md +56 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/Makefile +17 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/README.md +34 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/middleware.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/benchmarks/run +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/README.md +29 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/index.js +134 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/foot.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/head.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/auth/views/login.ejs +21 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/db.js +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/index.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/content-negotiation/users.js +19 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/cookie-sessions/index.js +25 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/cookies/index.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/CCTV/345/244/247/350/265/233/344/270/212/346/265/267/345/210/206/350/265/233/345/214/272.txt +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/amazing.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/files/notes/groceries.txt +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/downloads/index.js +40 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/index.js +57 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/public/stylesheets/style.css +4 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/footer.html +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/header.html +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/ejs/views/users.html +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error/index.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/index.js +103 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/404.ejs +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/500.ejs +8 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/error_header.ejs +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/footer.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/error-pages/views/index.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/hello-world/index.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/index.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/markdown/views/index.md +4 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v1.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/controllers/api_v2.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/multi-router/index.js +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/main/index.js +5 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/index.js +31 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/edit.ejs +17 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/pet/views/show.ejs +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/index.js +41 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/edit.hbs +27 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/list.hbs +18 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user/views/show.hbs +31 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/controllers/user-pet/index.js +22 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/db.js +16 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/index.js +95 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/lib/boot.js +83 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/public/style.css +14 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/404.ejs +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/mvc/views/5xx.ejs +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/online/index.js +61 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/params/index.js +74 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/resource/index.js +95 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-map/index.js +75 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-middleware/index.js +90 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/index.js +55 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/post.js +13 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/public/style.css +24 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/site.js +5 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/user.js +47 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/footer.ejs +2 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/header.ejs +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/index.ejs +10 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/posts/index.ejs +12 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/edit.ejs +23 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/index.ejs +14 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/route-separation/views/users/view.ejs +9 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/index.js +61 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/client.js +15 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/search/public/index.html +21 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/session/index.js +37 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/session/redis.js +39 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/index.js +43 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/css/style.css +3 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/hello.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/static-files/public/js/app.js +1 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/vhost/index.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/github-view.js +53 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-constructor/index.js +48 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/index.js +155 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/user.js +36 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/view-locals/views/index.ejs +20 -0
- package/tests/fixtures/corpus/oss-repos/express/examples/web-service/index.js +117 -0
- package/tests/fixtures/corpus/oss-repos/express/index.js +11 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/application.js +631 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/express.js +81 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/request.js +514 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/response.js +1053 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/utils.js +271 -0
- package/tests/fixtures/corpus/oss-repos/express/lib/view.js +205 -0
- package/tests/fixtures/corpus/oss-repos/express/package.json +99 -0
- package/tests/fixtures/corpus/oss-repos/express/test/Route.js +274 -0
- package/tests/fixtures/corpus/oss-repos/express/test/Router.js +636 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/auth.js +117 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/content-negotiation.js +49 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookie-sessions.js +38 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/cookies.js +71 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/downloads.js +47 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/ejs.js +17 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error-pages.js +99 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/error.js +29 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/hello-world.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/markdown.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/multi-router.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/mvc.js +132 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/params.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/resource.js +68 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-map.js +45 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/route-separation.js +97 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/vhost.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/test/acceptance/web-service.js +105 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.all.js +38 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.engine.js +83 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.head.js +66 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.js +120 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.listen.js +55 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.locals.js +26 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.options.js +116 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.param.js +323 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.render.js +374 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.request.js +143 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.response.js +143 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.route.js +197 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.router.js +1217 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.routes.error.js +62 -0
- package/tests/fixtures/corpus/oss-repos/express/test/app.use.js +542 -0
- package/tests/fixtures/corpus/oss-repos/express/test/config.js +207 -0
- package/tests/fixtures/corpus/oss-repos/express/test/exports.js +82 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.json.js +755 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.raw.js +513 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.static.js +815 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.text.js +566 -0
- package/tests/fixtures/corpus/oss-repos/express/test/express.urlencoded.js +828 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/% of dogs.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/.name +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/index.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/blog/post/index.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/broken.send +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/name.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/default_layout/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/email.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/empty.txt +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/local_layout/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/name.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/nums.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/pets/names.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/snow /342/230/203/.gitkeep +0 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/todo.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/user.tmpl +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/index.html +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/fixtures/users/tobi.txt +1 -0
- package/tests/fixtures/corpus/oss-repos/express/test/middleware.basic.js +42 -0
- package/tests/fixtures/corpus/oss-repos/express/test/regression.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.accepts.js +125 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsCharsets.js +50 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsEncodings.js +39 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.acceptsLanguages.js +57 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.baseUrl.js +88 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.fresh.js +70 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.get.js +60 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.host.js +156 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.hostname.js +188 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.ip.js +113 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.ips.js +71 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.is.js +169 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.path.js +20 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.protocol.js +113 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.query.js +106 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.range.js +104 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.route.js +28 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.secure.js +101 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.signedCookies.js +37 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.stale.js +50 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.subdomains.js +173 -0
- package/tests/fixtures/corpus/oss-repos/express/test/req.xhr.js +42 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.append.js +116 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.attachment.js +79 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.clearCookie.js +62 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.cookie.js +295 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.download.js +487 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.format.js +248 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.get.js +21 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.json.js +186 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.jsonp.js +344 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.links.js +65 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.locals.js +40 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.location.js +316 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.redirect.js +214 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.render.js +367 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.send.js +569 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendFile.js +913 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.sendStatus.js +44 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.set.js +124 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.status.js +206 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.type.js +46 -0
- package/tests/fixtures/corpus/oss-repos/express/test/res.vary.js +90 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/env.js +3 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/tmpl.js +36 -0
- package/tests/fixtures/corpus/oss-repos/express/test/support/utils.js +86 -0
- package/tests/fixtures/corpus/oss-repos/express/test/utils.js +83 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/Dockerfile +11 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/devcontainer.json +21 -0
- package/tests/fixtures/corpus/oss-repos/hono/.devcontainer/docker-compose.yml +18 -0
- package/tests/fixtures/corpus/oss-repos/hono/.eslintignore +1 -0
- package/tests/fixtures/corpus/oss-repos/hono/.eslintrc.cjs +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.gitpod.yml +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.prettierrc +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-default.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/jsx-runtime-dom.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/.vitest.config/setup-vitest.ts +47 -0
- package/tests/fixtures/corpus/oss-repos/hono/LICENSE +21 -0
- package/tests/fixtures/corpus/oss-repos/hono/README.md +91 -0
- package/tests/fixtures/corpus/oss-repos/hono/build.ts +80 -0
- package/tests/fixtures/corpus/oss-repos/hono/bun.lockb +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/bunfig.toml +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/codecov.yml +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/CODE_OF_CONDUCT.md +128 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/CONTRIBUTING.md +62 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/MIGRATION.md +295 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.png +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.pxm +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-logo.svg +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.png +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/docs/images/hono-title.pxm +0 -0
- package/tests/fixtures/corpus/oss-repos/hono/jsr.json +119 -0
- package/tests/fixtures/corpus/oss-repos/hono/package.cjs.json +3 -0
- package/tests/fixtures/corpus/oss-repos/hono/package.json +650 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +492 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/types.ts +144 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/conninfo.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/serve-static.ts +35 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/server.ts +30 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/ssg.ts +27 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/bun/websocket.ts +110 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +120 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/conninfo.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static-module.ts +12 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +39 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/utils.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/websocket.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/conninfo.ts +17 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/deno.d.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/serve-static.ts +40 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/ssg.ts +27 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/deno/websocket.ts +51 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/conninfo.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/handler.ts +189 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/lambda-edge/index.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/handler.ts +10 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/netlify/mod.ts +1 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/handler.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/index.ts +5 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/service-worker/types.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/conninfo.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/handler.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/vercel/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +214 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/index.ts +14 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +180 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/client/utils.ts +54 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/compose.ts +94 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +914 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +81 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +85 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/conninfo/types.ts +45 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/cookie/index.ts +130 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/common.ts +243 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +220 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/dev/index.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +246 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/html/index.ts +56 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/middleware.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +388 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/utils.ts +71 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/index.ts +9 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/sse.ts +89 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/stream.ts +36 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/streaming/text.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/testing/index.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/websocket/index.ts +57 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +523 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/http-exception.ts +78 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/index.ts +51 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/base.ts +419 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/children.ts +20 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/components.ts +195 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/constants.ts +5 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/context.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/client.ts +89 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/components.ts +39 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/context.ts +52 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +246 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/hooks/index.ts +91 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/index.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +398 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-dev-runtime.ts +22 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/jsx-runtime.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +772 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/server.ts +70 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/utils.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +426 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/index.ts +114 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/common.ts +11 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +196 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-elements.ts +924 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-dev-runtime.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/jsx-runtime.ts +18 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/streaming.ts +184 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/types.ts +41 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +36 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/basic-auth/index.ts +128 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/bearer-auth/index.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/body-limit/index.ts +115 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cache/index.ts +127 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/combine/index.ts +153 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/compress/index.ts +79 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/context-storage/index.ts +55 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/cors/index.ts +141 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/csrf/index.ts +90 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/etag/index.ts +88 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/ip-restriction/index.ts +178 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +158 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jwt/jwt.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/logger/index.ts +93 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/method-override/index.ts +146 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/powered-by/index.ts +13 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/pretty-json/index.ts +50 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/request-id/request-id.ts +59 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/index.ts +8 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/permissions-policy.ts +86 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/secure-headers/secure-headers.ts +319 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +140 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timeout/index.ts +58 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/timing/timing.ts +225 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/trailing-slash/index.ts +71 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +24 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +20 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/request.ts +403 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/linear-router/router.ts +132 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +54 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +159 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +274 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/trie.ts +74 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/smart-router/router.ts +69 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/index.ts +6 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +205 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/router.ts +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/router.ts +103 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +2009 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/basic-auth.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +225 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/buffer.ts +65 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +26 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/concurrent.ts +55 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +230 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/crypto.ts +65 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/filepath.ts +56 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/handler.ts +15 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/html.ts +182 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/http-status.ts +69 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/ipaddr.ts +113 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwa.ts +23 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jws.ts +226 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/jwt.ts +114 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/types.ts +83 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/jwt/utf8.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/mime.ts +142 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/stream.ts +96 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +105 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/url.ts +310 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/index.ts +7 -0
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +151 -0
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.build.json +23 -0
- package/tests/fixtures/corpus/oss-repos/hono/tsconfig.json +28 -0
- package/tests/fixtures/corpus/oss-repos/hono/vitest.config.ts +34 -0
- package/tests/fixtures/corpus/oss-repos/hono/yarn.lock +6232 -0
- package/tests/fixtures/documentation/api-reference.md +412 -0
- package/tests/fixtures/documentation/architecture.md +214 -0
- package/tests/fixtures/documentation/deployment-guide.md +420 -0
- package/tests/fixtures/github-readmes/express.md +133 -0
- package/tests/fixtures/github-readmes/nextjs.md +106 -0
- package/tests/fixtures/github-readmes/react.md +74 -0
- package/tests/fixtures/github-readmes/typescript.md +93 -0
- package/tests/fixtures/github-readmes/vite.md +79 -0
- package/tests/fixtures/queries/core.json +125 -0
- package/tests/fixtures/queries/extended.json +427 -0
- package/tests/fixtures/queries/generated/.gitkeep +0 -0
- package/tests/fixtures/test-server.ts +267 -0
- package/tests/helpers/performance-metrics.ts +387 -0
- package/tests/helpers/search-relevance.ts +381 -0
- package/tests/integration/cli-consistency.test.ts +299 -0
- package/tests/integration/cli.test.ts +69 -0
- package/tests/integration/e2e-workflow.test.ts +612 -0
- package/tests/integration/python-bridge.test.ts +183 -0
- package/tests/integration/search-quality.test.ts +718 -0
- package/tests/integration/stress.test.ts +326 -0
- package/tests/mcp/server.test.ts +15 -0
- package/tests/scripts/schemas/evaluation.json +44 -0
- package/tests/scripts/schemas/query-generation.json +21 -0
- package/tests/services/code-unit.service.test.ts +47 -0
- package/tests/services/search.progressive-context.test.ts +35 -0
- package/tsconfig.json +34 -0
- package/tsup.config.ts +15 -0
- package/turndown-plugin-gfm.d.ts +29 -0
- package/vitest.config.ts +79 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* This module is the base module for the Hono object.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
import { compose } from './compose'
|
|
8
|
+
import { Context } from './context'
|
|
9
|
+
import type { ExecutionContext } from './context'
|
|
10
|
+
import type { Router } from './router'
|
|
11
|
+
import { METHODS, METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from './router'
|
|
12
|
+
import type {
|
|
13
|
+
Env,
|
|
14
|
+
ErrorHandler,
|
|
15
|
+
FetchEventLike,
|
|
16
|
+
H,
|
|
17
|
+
HTTPResponseError,
|
|
18
|
+
HandlerInterface,
|
|
19
|
+
MergePath,
|
|
20
|
+
MergeSchemaPath,
|
|
21
|
+
MiddlewareHandler,
|
|
22
|
+
MiddlewareHandlerInterface,
|
|
23
|
+
Next,
|
|
24
|
+
NotFoundHandler,
|
|
25
|
+
OnHandlerInterface,
|
|
26
|
+
RouterRoute,
|
|
27
|
+
Schema,
|
|
28
|
+
} from './types'
|
|
29
|
+
import { getPath, getPathNoStrict, mergePath } from './utils/url'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Symbol used to mark a composed handler.
|
|
33
|
+
*/
|
|
34
|
+
export const COMPOSED_HANDLER = Symbol('composedHandler')
|
|
35
|
+
|
|
36
|
+
const notFoundHandler = (c: Context) => {
|
|
37
|
+
return c.text('404 Not Found', 404)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const errorHandler = (err: Error | HTTPResponseError, c: Context) => {
|
|
41
|
+
if ('getResponse' in err) {
|
|
42
|
+
return err.getResponse()
|
|
43
|
+
}
|
|
44
|
+
console.error(err)
|
|
45
|
+
return c.text('Internal Server Error', 500)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type GetPath<E extends Env> = (request: Request, options?: { env?: E['Bindings'] }) => string
|
|
49
|
+
|
|
50
|
+
export type HonoOptions<E extends Env> = {
|
|
51
|
+
/**
|
|
52
|
+
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://hono.dev/docs/api/hono#strict-mode}
|
|
55
|
+
*
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
strict?: boolean
|
|
59
|
+
/**
|
|
60
|
+
* `router` option specifices which router to use.
|
|
61
|
+
*
|
|
62
|
+
* @see {@link https://hono.dev/docs/api/hono#router-option}
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const app = new Hono({ router: new RegExpRouter() })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
router?: Router<[H, RouterRoute]>
|
|
70
|
+
/**
|
|
71
|
+
* `getPath` can handle the host header value.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://hono.dev/docs/api/routing#routing-with-host-header-value}
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const app = new Hono({
|
|
78
|
+
* getPath: (req) =>
|
|
79
|
+
* '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
|
|
80
|
+
* })
|
|
81
|
+
*
|
|
82
|
+
* app.get('/www1.example.com/hello', () => c.text('hello www1'))
|
|
83
|
+
*
|
|
84
|
+
* // A following request will match the route:
|
|
85
|
+
* // new Request('http://www1.example.com/hello', {
|
|
86
|
+
* // headers: { host: 'www1.example.com' },
|
|
87
|
+
* // })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
getPath?: GetPath<E>
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type MountOptionHandler = (c: Context) => unknown
|
|
94
|
+
type MountReplaceRequest = (originalRequest: Request) => Request
|
|
95
|
+
type MountOptions =
|
|
96
|
+
| MountOptionHandler
|
|
97
|
+
| {
|
|
98
|
+
optionHandler?: MountOptionHandler
|
|
99
|
+
replaceRequest?: MountReplaceRequest
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
|
|
103
|
+
get!: HandlerInterface<E, 'get', S, BasePath>
|
|
104
|
+
post!: HandlerInterface<E, 'post', S, BasePath>
|
|
105
|
+
put!: HandlerInterface<E, 'put', S, BasePath>
|
|
106
|
+
delete!: HandlerInterface<E, 'delete', S, BasePath>
|
|
107
|
+
options!: HandlerInterface<E, 'options', S, BasePath>
|
|
108
|
+
patch!: HandlerInterface<E, 'patch', S, BasePath>
|
|
109
|
+
all!: HandlerInterface<E, 'all', S, BasePath>
|
|
110
|
+
on: OnHandlerInterface<E, S, BasePath>
|
|
111
|
+
use: MiddlewareHandlerInterface<E, S, BasePath>
|
|
112
|
+
|
|
113
|
+
/*
|
|
114
|
+
This class is like an abstract class and does not have a router.
|
|
115
|
+
To use it, inherit the class and implement router in the constructor.
|
|
116
|
+
*/
|
|
117
|
+
router!: Router<[H, RouterRoute]>
|
|
118
|
+
readonly getPath: GetPath<E>
|
|
119
|
+
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
120
|
+
private _basePath: string = '/'
|
|
121
|
+
#path: string = '/'
|
|
122
|
+
|
|
123
|
+
routes: RouterRoute[] = []
|
|
124
|
+
|
|
125
|
+
constructor(options: HonoOptions<E> = {}) {
|
|
126
|
+
// Implementation of app.get(...handlers[]) or app.get(path, ...handlers[])
|
|
127
|
+
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]
|
|
128
|
+
allMethods.forEach((method) => {
|
|
129
|
+
this[method] = (args1: string | H, ...args: H[]) => {
|
|
130
|
+
if (typeof args1 === 'string') {
|
|
131
|
+
this.#path = args1
|
|
132
|
+
} else {
|
|
133
|
+
this.addRoute(method, this.#path, args1)
|
|
134
|
+
}
|
|
135
|
+
args.forEach((handler) => {
|
|
136
|
+
if (typeof handler !== 'string') {
|
|
137
|
+
this.addRoute(method, this.#path, handler)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
return this as any
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
// Implementation of app.on(method, path, ...handlers[])
|
|
145
|
+
this.on = (method: string | string[], path: string | string[], ...handlers: H[]) => {
|
|
146
|
+
for (const p of [path].flat()) {
|
|
147
|
+
this.#path = p
|
|
148
|
+
for (const m of [method].flat()) {
|
|
149
|
+
handlers.map((handler) => {
|
|
150
|
+
this.addRoute(m.toUpperCase(), this.#path, handler)
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return this as any
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Implementation of app.use(...handlers[]) or app.use(path, ...handlers[])
|
|
158
|
+
this.use = (arg1: string | MiddlewareHandler<any>, ...handlers: MiddlewareHandler<any>[]) => {
|
|
159
|
+
if (typeof arg1 === 'string') {
|
|
160
|
+
this.#path = arg1
|
|
161
|
+
} else {
|
|
162
|
+
this.#path = '*'
|
|
163
|
+
handlers.unshift(arg1)
|
|
164
|
+
}
|
|
165
|
+
handlers.forEach((handler) => {
|
|
166
|
+
this.addRoute(METHOD_NAME_ALL, this.#path, handler)
|
|
167
|
+
})
|
|
168
|
+
return this as any
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const strict = options.strict ?? true
|
|
172
|
+
delete options.strict
|
|
173
|
+
Object.assign(this, options)
|
|
174
|
+
this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private clone(): Hono<E, S, BasePath> {
|
|
178
|
+
const clone = new Hono<E, S, BasePath>({
|
|
179
|
+
router: this.router,
|
|
180
|
+
getPath: this.getPath,
|
|
181
|
+
})
|
|
182
|
+
clone.routes = this.routes
|
|
183
|
+
return clone
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private notFoundHandler: NotFoundHandler = notFoundHandler
|
|
187
|
+
private errorHandler: ErrorHandler = errorHandler
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* `.route()` allows grouping other Hono instance in routes.
|
|
191
|
+
*
|
|
192
|
+
* @see {@link https://hono.dev/docs/api/routing#grouping}
|
|
193
|
+
*
|
|
194
|
+
* @param {string} path - base Path
|
|
195
|
+
* @param {Hono} app - other Hono instance
|
|
196
|
+
* @returns {Hono} routed Hono instance
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const app = new Hono()
|
|
201
|
+
* const app2 = new Hono()
|
|
202
|
+
*
|
|
203
|
+
* app2.get("/user", (c) => c.text("user"))
|
|
204
|
+
* app.route("/api", app2) // GET /api/user
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
route<
|
|
208
|
+
SubPath extends string,
|
|
209
|
+
SubEnv extends Env,
|
|
210
|
+
SubSchema extends Schema,
|
|
211
|
+
SubBasePath extends string
|
|
212
|
+
>(
|
|
213
|
+
path: SubPath,
|
|
214
|
+
app: Hono<SubEnv, SubSchema, SubBasePath>
|
|
215
|
+
): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {
|
|
216
|
+
const subApp = this.basePath(path)
|
|
217
|
+
app.routes.map((r) => {
|
|
218
|
+
let handler
|
|
219
|
+
if (app.errorHandler === errorHandler) {
|
|
220
|
+
handler = r.handler
|
|
221
|
+
} else {
|
|
222
|
+
handler = async (c: Context, next: Next) =>
|
|
223
|
+
(await compose<Context>([], app.errorHandler)(c, () => r.handler(c, next))).res
|
|
224
|
+
;(handler as any)[COMPOSED_HANDLER] = r.handler
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
subApp.addRoute(r.method, r.path, handler)
|
|
228
|
+
})
|
|
229
|
+
return this
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* `.basePath()` allows base paths to be specified.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://hono.dev/docs/api/routing#base-path}
|
|
236
|
+
*
|
|
237
|
+
* @param {string} path - base Path
|
|
238
|
+
* @returns {Hono} changed Hono instance
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const api = new Hono().basePath('/api')
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>> {
|
|
246
|
+
const subApp = this.clone()
|
|
247
|
+
subApp._basePath = mergePath(this._basePath, path)
|
|
248
|
+
return subApp
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* `.onError()` handles an error and returns a customized Response.
|
|
253
|
+
*
|
|
254
|
+
* @see {@link https://hono.dev/docs/api/hono#error-handling}
|
|
255
|
+
*
|
|
256
|
+
* @param {ErrorHandler} handler - request Handler for error
|
|
257
|
+
* @returns {Hono} changed Hono instance
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* app.onError((err, c) => {
|
|
262
|
+
* console.error(`${err}`)
|
|
263
|
+
* return c.text('Custom Error Message', 500)
|
|
264
|
+
* })
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
onError = (handler: ErrorHandler<E>): Hono<E, S, BasePath> => {
|
|
268
|
+
this.errorHandler = handler
|
|
269
|
+
return this
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* `.notFound()` allows you to customize a Not Found Response.
|
|
274
|
+
*
|
|
275
|
+
* @see {@link https://hono.dev/docs/api/hono#not-found}
|
|
276
|
+
*
|
|
277
|
+
* @param {NotFoundHandler} handler - request handler for not-found
|
|
278
|
+
* @returns {Hono} changed Hono instance
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* app.notFound((c) => {
|
|
283
|
+
* return c.text('Custom 404 Message', 404)
|
|
284
|
+
* })
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
notFound = (handler: NotFoundHandler<E>): Hono<E, S, BasePath> => {
|
|
288
|
+
this.notFoundHandler = handler
|
|
289
|
+
return this
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* `.mount()` allows you to mount applications built with other frameworks into your Hono application.
|
|
294
|
+
*
|
|
295
|
+
* @see {@link https://hono.dev/docs/api/hono#mount}
|
|
296
|
+
*
|
|
297
|
+
* @param {string} path - base Path
|
|
298
|
+
* @param {Function} applicationHandler - other Request Handler
|
|
299
|
+
* @param {MountOptions} [options] - options of `.mount()`
|
|
300
|
+
* @returns {Hono} mounted Hono instance
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* import { Router as IttyRouter } from 'itty-router'
|
|
305
|
+
* import { Hono } from 'hono'
|
|
306
|
+
* // Create itty-router application
|
|
307
|
+
* const ittyRouter = IttyRouter()
|
|
308
|
+
* // GET /itty-router/hello
|
|
309
|
+
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
310
|
+
*
|
|
311
|
+
* const app = new Hono()
|
|
312
|
+
* app.mount('/itty-router', ittyRouter.handle)
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* const app = new Hono()
|
|
318
|
+
* // Send the request to another application without modification.
|
|
319
|
+
* app.mount('/app', anotherApp, {
|
|
320
|
+
* replaceRequest: (req) => req,
|
|
321
|
+
* })
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
mount(
|
|
325
|
+
path: string,
|
|
326
|
+
applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>,
|
|
327
|
+
options?: MountOptions
|
|
328
|
+
): Hono<E, S, BasePath> {
|
|
329
|
+
// handle options
|
|
330
|
+
let replaceRequest: MountReplaceRequest | undefined
|
|
331
|
+
let optionHandler: MountOptionHandler | undefined
|
|
332
|
+
if (options) {
|
|
333
|
+
if (typeof options === 'function') {
|
|
334
|
+
optionHandler = options
|
|
335
|
+
} else {
|
|
336
|
+
optionHandler = options.optionHandler
|
|
337
|
+
replaceRequest = options.replaceRequest
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// prepare handlers for request
|
|
342
|
+
const getOptions: (c: Context) => unknown[] = optionHandler
|
|
343
|
+
? (c) => {
|
|
344
|
+
const options = optionHandler!(c)
|
|
345
|
+
return Array.isArray(options) ? options : [options]
|
|
346
|
+
}
|
|
347
|
+
: (c) => {
|
|
348
|
+
let executionContext: ExecutionContext | undefined = undefined
|
|
349
|
+
try {
|
|
350
|
+
executionContext = c.executionCtx
|
|
351
|
+
} catch {} // Do nothing
|
|
352
|
+
return [c.env, executionContext]
|
|
353
|
+
}
|
|
354
|
+
replaceRequest ||= (() => {
|
|
355
|
+
const mergedPath = mergePath(this._basePath, path)
|
|
356
|
+
const pathPrefixLength = mergedPath === '/' ? 0 : mergedPath.length
|
|
357
|
+
return (request) => {
|
|
358
|
+
const url = new URL(request.url)
|
|
359
|
+
url.pathname = url.pathname.slice(pathPrefixLength) || '/'
|
|
360
|
+
return new Request(url, request)
|
|
361
|
+
}
|
|
362
|
+
})()
|
|
363
|
+
|
|
364
|
+
const handler: MiddlewareHandler = async (c, next) => {
|
|
365
|
+
const res = await applicationHandler(replaceRequest!(c.req.raw), ...getOptions(c))
|
|
366
|
+
|
|
367
|
+
if (res) {
|
|
368
|
+
return res
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
await next()
|
|
372
|
+
}
|
|
373
|
+
this.addRoute(METHOD_NAME_ALL, mergePath(path, '*'), handler)
|
|
374
|
+
return this
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
private addRoute(method: string, path: string, handler: H) {
|
|
378
|
+
method = method.toUpperCase()
|
|
379
|
+
path = mergePath(this._basePath, path)
|
|
380
|
+
const r: RouterRoute = { path: path, method: method, handler: handler }
|
|
381
|
+
this.router.add(method, path, [handler, r])
|
|
382
|
+
this.routes.push(r)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
private matchRoute(method: string, path: string) {
|
|
386
|
+
return this.router.match(method, path)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
private handleError(err: unknown, c: Context<E>) {
|
|
390
|
+
if (err instanceof Error) {
|
|
391
|
+
return this.errorHandler(err, c)
|
|
392
|
+
}
|
|
393
|
+
throw err
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private dispatch(
|
|
397
|
+
request: Request,
|
|
398
|
+
executionCtx: ExecutionContext | FetchEventLike | undefined,
|
|
399
|
+
env: E['Bindings'],
|
|
400
|
+
method: string
|
|
401
|
+
): Response | Promise<Response> {
|
|
402
|
+
// Handle HEAD method
|
|
403
|
+
if (method === 'HEAD') {
|
|
404
|
+
return (async () =>
|
|
405
|
+
new Response(null, await this.dispatch(request, executionCtx, env, 'GET')))()
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const path = this.getPath(request, { env })
|
|
409
|
+
const matchResult = this.matchRoute(method, path)
|
|
410
|
+
|
|
411
|
+
const c = new Context(request, {
|
|
412
|
+
path,
|
|
413
|
+
matchResult,
|
|
414
|
+
env,
|
|
415
|
+
executionCtx,
|
|
416
|
+
notFoundHandler: this.notFoundHandler,
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
// Do not `compose` if it has only one handler
|
|
420
|
+
if (matchResult[0].length === 1) {
|
|
421
|
+
let res: ReturnType<H>
|
|
422
|
+
try {
|
|
423
|
+
res = matchResult[0][0][0][0](c, async () => {
|
|
424
|
+
c.res = await this.notFoundHandler(c)
|
|
425
|
+
})
|
|
426
|
+
} catch (err) {
|
|
427
|
+
return this.handleError(err, c)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return res instanceof Promise
|
|
431
|
+
? res
|
|
432
|
+
.then(
|
|
433
|
+
(resolved: Response | undefined) =>
|
|
434
|
+
resolved || (c.finalized ? c.res : this.notFoundHandler(c))
|
|
435
|
+
)
|
|
436
|
+
.catch((err: Error) => this.handleError(err, c))
|
|
437
|
+
: res ?? this.notFoundHandler(c)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const composed = compose<Context>(matchResult[0], this.errorHandler, this.notFoundHandler)
|
|
441
|
+
|
|
442
|
+
return (async () => {
|
|
443
|
+
try {
|
|
444
|
+
const context = await composed(c)
|
|
445
|
+
if (!context.finalized) {
|
|
446
|
+
throw new Error(
|
|
447
|
+
'Context is not finalized. Did you forget to return a Response object or `await next()`?'
|
|
448
|
+
)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return context.res
|
|
452
|
+
} catch (err) {
|
|
453
|
+
return this.handleError(err, c)
|
|
454
|
+
}
|
|
455
|
+
})()
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* `.fetch()` will be entry point of your app.
|
|
460
|
+
*
|
|
461
|
+
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
462
|
+
*
|
|
463
|
+
* @param {Request} request - request Object of request
|
|
464
|
+
* @param {Env} Env - env Object
|
|
465
|
+
* @param {ExecutionContext} - context of execution
|
|
466
|
+
* @returns {Response | Promise<Response>} response of request
|
|
467
|
+
*
|
|
468
|
+
*/
|
|
469
|
+
fetch: (
|
|
470
|
+
request: Request,
|
|
471
|
+
Env?: E['Bindings'] | {},
|
|
472
|
+
executionCtx?: ExecutionContext
|
|
473
|
+
) => Response | Promise<Response> = (request, ...rest) => {
|
|
474
|
+
return this.dispatch(request, rest[1], rest[0], request.method)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* `.request()` is a useful method for testing.
|
|
479
|
+
* You can pass a URL or pathname to send a GET request.
|
|
480
|
+
* app will return a Response object.
|
|
481
|
+
* ```ts
|
|
482
|
+
* test('GET /hello is ok', async () => {
|
|
483
|
+
* const res = await app.request('/hello')
|
|
484
|
+
* expect(res.status).toBe(200)
|
|
485
|
+
* })
|
|
486
|
+
* ```
|
|
487
|
+
* @see https://hono.dev/docs/api/hono#request
|
|
488
|
+
*/
|
|
489
|
+
request = (
|
|
490
|
+
input: RequestInfo | URL,
|
|
491
|
+
requestInit?: RequestInit,
|
|
492
|
+
Env?: E['Bindings'] | {},
|
|
493
|
+
executionCtx?: ExecutionContext
|
|
494
|
+
): Response | Promise<Response> => {
|
|
495
|
+
if (input instanceof Request) {
|
|
496
|
+
if (requestInit !== undefined) {
|
|
497
|
+
input = new Request(input, requestInit)
|
|
498
|
+
}
|
|
499
|
+
return this.fetch(input, Env, executionCtx)
|
|
500
|
+
}
|
|
501
|
+
input = input.toString()
|
|
502
|
+
const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath('/', input)}`
|
|
503
|
+
const req = new Request(path, requestInit)
|
|
504
|
+
return this.fetch(req, Env, executionCtx)
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* `.fire()` automatically adds a global fetch event listener.
|
|
509
|
+
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
510
|
+
* @see https://hono.dev/docs/api/hono#fire
|
|
511
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
512
|
+
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
513
|
+
*/
|
|
514
|
+
fire = (): void => {
|
|
515
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
addEventListener('fetch', (event: FetchEventLike): void => {
|
|
518
|
+
event.respondWith(this.dispatch(event.request, event, undefined, event.request.method))
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export { Hono as HonoBase }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HonoBase } from './hono-base'
|
|
2
|
+
import type { HonoOptions } from './hono-base'
|
|
3
|
+
import { RegExpRouter } from './router/reg-exp-router'
|
|
4
|
+
import { SmartRouter } from './router/smart-router'
|
|
5
|
+
import { TrieRouter } from './router/trie-router'
|
|
6
|
+
import type { BlankEnv, BlankSchema, Env, Schema } from './types'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The Hono class extends the functionality of the HonoBase class.
|
|
10
|
+
* It sets up routing and allows for custom options to be passed.
|
|
11
|
+
*
|
|
12
|
+
* @template E - The environment type.
|
|
13
|
+
* @template S - The schema type.
|
|
14
|
+
* @template BasePath - The base path type.
|
|
15
|
+
*/
|
|
16
|
+
export class Hono<
|
|
17
|
+
E extends Env = BlankEnv,
|
|
18
|
+
S extends Schema = BlankSchema,
|
|
19
|
+
BasePath extends string = '/'
|
|
20
|
+
> extends HonoBase<E, S, BasePath> {
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance of the Hono class.
|
|
23
|
+
*
|
|
24
|
+
* @param options - Optional configuration options for the Hono instance.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: HonoOptions<E> = {}) {
|
|
27
|
+
super(options)
|
|
28
|
+
this.router =
|
|
29
|
+
options.router ??
|
|
30
|
+
new SmartRouter({
|
|
31
|
+
routers: [new RegExpRouter(), new TrieRouter()],
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* This module provides the `HTTPException` class.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { StatusCode } from './utils/http-status'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating an `HTTPException`.
|
|
10
|
+
* @property res - Optional response object to use.
|
|
11
|
+
* @property message - Optional custom error message.
|
|
12
|
+
* @property cause - Optional cause of the error.
|
|
13
|
+
*/
|
|
14
|
+
type HTTPExceptionOptions = {
|
|
15
|
+
res?: Response
|
|
16
|
+
message?: string
|
|
17
|
+
cause?: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://hono.dev/docs/api/exception}
|
|
24
|
+
*
|
|
25
|
+
* @param {StatusCode} status - status code of HTTPException
|
|
26
|
+
* @param {HTTPExceptionOptions} options - options of HTTPException
|
|
27
|
+
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
|
|
28
|
+
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
|
|
29
|
+
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { HTTPException } from 'hono/http-exception'
|
|
34
|
+
*
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* app.post('/auth', async (c, next) => {
|
|
38
|
+
* // authentication
|
|
39
|
+
* if (authorized === false) {
|
|
40
|
+
* throw new HTTPException(401, { message: 'Custom error message' })
|
|
41
|
+
* }
|
|
42
|
+
* await next()
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class HTTPException extends Error {
|
|
47
|
+
readonly res?: Response
|
|
48
|
+
readonly status: StatusCode
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates an instance of `HTTPException`.
|
|
52
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
53
|
+
* @param options - Additional options for the exception.
|
|
54
|
+
*/
|
|
55
|
+
constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {
|
|
56
|
+
super(options?.message, { cause: options?.cause })
|
|
57
|
+
this.res = options?.res
|
|
58
|
+
this.status = status
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the response object associated with the exception.
|
|
63
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
64
|
+
* @returns The response object.
|
|
65
|
+
*/
|
|
66
|
+
getResponse(): Response {
|
|
67
|
+
if (this.res) {
|
|
68
|
+
const newResponse = new Response(this.res.body, {
|
|
69
|
+
status: this.status,
|
|
70
|
+
headers: this.res.headers,
|
|
71
|
+
})
|
|
72
|
+
return newResponse
|
|
73
|
+
}
|
|
74
|
+
return new Response(this.message, {
|
|
75
|
+
status: this.status,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
*
|
|
4
|
+
* Hono - Web Framework built on Web Standards
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Hono } from 'hono'
|
|
9
|
+
* const app = new Hono()
|
|
10
|
+
*
|
|
11
|
+
* app.get('/', (c) => c.text('Hono!'))
|
|
12
|
+
*
|
|
13
|
+
* export default app
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { Hono } from './hono'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Types for environment variables, error handlers, handlers, middleware handlers, and more.
|
|
21
|
+
*/
|
|
22
|
+
export type {
|
|
23
|
+
Env,
|
|
24
|
+
ErrorHandler,
|
|
25
|
+
Handler,
|
|
26
|
+
MiddlewareHandler,
|
|
27
|
+
Next,
|
|
28
|
+
NotFoundHandler,
|
|
29
|
+
ValidationTargets,
|
|
30
|
+
Input,
|
|
31
|
+
Schema,
|
|
32
|
+
ToSchema,
|
|
33
|
+
TypedResponse,
|
|
34
|
+
} from './types'
|
|
35
|
+
/**
|
|
36
|
+
* Types for context, context variable map, context renderer, and execution context.
|
|
37
|
+
*/
|
|
38
|
+
export type { Context, ContextVariableMap, ContextRenderer, ExecutionContext } from './context'
|
|
39
|
+
/**
|
|
40
|
+
* Type for HonoRequest.
|
|
41
|
+
*/
|
|
42
|
+
export type { HonoRequest } from './request'
|
|
43
|
+
/**
|
|
44
|
+
* Types for inferring request and response types and client request options.
|
|
45
|
+
*/
|
|
46
|
+
export type { InferRequestType, InferResponseType, ClientRequestOptions } from './client'
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Hono framework for building web applications.
|
|
50
|
+
*/
|
|
51
|
+
export { Hono }
|