{"id":15408533,"url":"https://github.com/yusukebe/h-web-router","last_synced_at":"2025-06-11T08:07:59.214Z","repository":{"id":230176679,"uuid":"778667266","full_name":"yusukebe/h-web-router","owner":"yusukebe","description":"H - Ultra-small Web Router built with Hono's Pattern Router","archived":false,"fork":false,"pushed_at":"2024-03-28T07:03:13.000Z","size":22,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T14:58:29.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusukebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-28T06:50:42.000Z","updated_at":"2024-12-22T05:59:23.000Z","dependencies_parsed_at":"2024-03-28T08:23:18.620Z","dependency_job_id":"dc3b790f-2a7f-4799-8e49-4794e2df3713","html_url":"https://github.com/yusukebe/h-web-router","commit_stats":null,"previous_names":["yusukebe/h-web-router"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fh-web-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fh-web-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fh-web-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fh-web-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusukebe","download_url":"https://codeload.github.com/yusukebe/h-web-router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fh-web-router/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259227951,"owners_count":22824903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T16:34:22.974Z","updated_at":"2025-06-11T08:07:59.195Z","avatar_url":"https://github.com/yusukebe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# H - Ultra-small Web Router\n\nH is an Ultra-small Web Router built with Hono's Pattern Router.\n\n## Features\n\n- Ultra Small - A \"Hello World\" application will be ~1KB (minified+gzipped).\n- Perfected Router - Using [Hono](https://hono.dev)'s Pattern Router. It's flexible, supports many patterns, and is well-tested.\n- Web Standards - Runs on Cloudflare Workers, Bun, Deno, and others.\n- Optimized with Cloudflare Workers - Supports Bindings and Execution Context.\n\n## Install\n\n```txt\nnpm i h-web-router\n// Or\nyarn add h-web-router\n```\n\n## Example\n\n```ts\nimport { app } from 'h-web-router'\n\n// handle a GET request and return a TEXT response\napp.get('/', () =\u003e new Response('Hi!'))\n\n// capture path parameters and return a JSON response\napp.post('/entry/:id', ({ params }) =\u003e {\n  return Response.json({\n    'your id is': params['id']\n  })\n})\n// capture path parameters with RegExp\napp.get('/posts/:date{\\\\d+}/:title{[a-z]+}', ({ params }) =\u003e {\n  const { date, title } = params\n  return Response.json({ post: { date, title } })\n})\n\n// get query parameters\napp.get('/search', ({ req }) =\u003e {\n  console.log(req.url)\n  const query = new URL(req.url).searchParams.get('q')\n  return new Response(`Your query is ${query}`)\n})\n\n// handle a PURGE method and return a Redirect response\napp.on('PURGE', '/cache', () =\u003e {\n  return new Response(null, {\n    status: 302,\n    headers: {\n      Location: '/'\n    }\n  })\n})\n\n// get environment variables for Cloudflare Workers\napp.get('/secret', ({ env }) =\u003e {\n  console.log(env.TOKEN)\n  return new Response('Welcome!')\n})\n\n// use an executionContext for Cloudflare Workers\napp.get('/log', ({ ctx, req }) =\u003e {\n  ctx.waitUntil((async () =\u003e console.log(`You access ${req.url.toString()}`))())\n  return new Response('log will be shown')\n})\n\n// return a custom 404 response\napp.get('*', () =\u003e {\n  return new Response('Custom 404', {\n    status: 404\n  })\n})\n\n// export the app for Cloudflare Workers or Bun\nexport default app\n```\n\n## Author\n\nYusuke Wada\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fh-web-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusukebe%2Fh-web-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fh-web-router/lists"}