{"id":24373281,"url":"https://github.com/noblemajo/bun-route","last_synced_at":"2025-04-10T18:31:44.283Z","repository":{"id":257042151,"uuid":"857063550","full_name":"NobleMajo/bun-route","owner":"NobleMajo","description":"A fast, Express-like router for the high-performance bun.serve() HTTP server.","archived":false,"fork":false,"pushed_at":"2025-04-04T12:43:30.000Z","size":116,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T12:52:00.637Z","etag":null,"topics":["bun","bun-js-serve-http-router","bun-router","bun-serve","bunjs","contributions-welcome","express","express-js","express-like","expressjs","http","http-server","open-source","route","router"],"latest_commit_sha":null,"homepage":"https://github.com/NobleMajo/bun-route","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NobleMajo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2024-09-13T18:19:49.000Z","updated_at":"2025-04-04T12:43:33.000Z","dependencies_parsed_at":"2024-09-14T14:21:51.041Z","dependency_job_id":"14ba9e43-10e7-4c90-b242-bce08f86c501","html_url":"https://github.com/NobleMajo/bun-route","commit_stats":null,"previous_names":["noblemajo/bunrouter","noblemajo/bun-router","noblemajo/bun-route"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Fbun-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Fbun-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Fbun-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NobleMajo%2Fbun-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NobleMajo","download_url":"https://codeload.github.com/NobleMajo/bun-route/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271781,"owners_count":21075800,"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":["bun","bun-js-serve-http-router","bun-router","bun-serve","bunjs","contributions-welcome","express","express-js","express-like","expressjs","http","http-server","open-source","route","router"],"created_at":"2025-01-19T05:10:31.005Z","updated_at":"2025-04-10T18:31:44.266Z","avatar_url":"https://github.com/NobleMajo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bun-route\n![CI/CD](https://github.com/noblemajo/bun-route/actions/workflows/npm-publish.yml/badge.svg)\n![MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n![typescript](https://img.shields.io/badge/dynamic/json?style=plastic\u0026color=blue\u0026label=Typescript\u0026prefix=v\u0026query=peerDependencies.typescript\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fnoblemajo%2Fbun-route%2Fmain%2Fpackage.json)\n![npm](https://img.shields.io/npm/v/bun-route.svg?style=plastic\u0026logo=npm\u0026color=red)\n\u003c!-- ![github](https://img.shields.io/badge/dynamic/json?style=plastic\u0026color=darkviolet\u0026label=GitHub\u0026prefix=v\u0026query=version\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2Fnoblemajo%2Fbun-route%2Fmain%2Fpackage.json) --\u003e\n\n![](https://img.shields.io/badge/dynamic/json?color=green\u0026label=watchers\u0026query=watchers\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)\n![](https://img.shields.io/badge/dynamic/json?color=yellow\u0026label=stars\u0026query=stargazers_count\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)\n![](https://img.shields.io/badge/dynamic/json?color=navy\u0026label=forks\u0026query=forks\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)\n\u003c!-- ![](https://img.shields.io/badge/dynamic/json?color=darkred\u0026label=open%20issues\u0026query=open_issues\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route)\n![](https://img.shields.io/badge/dynamic/json?color=orange\u0026label=subscribers\u0026query=subscribers_count\u0026suffix=x\u0026url=https%3A%2F%2Fapi.github.com%2Frepos%2Fnoblemajo%2Fbun-route) --\u003e\n\n**A fast, Express-like router for the high-performance `bun.serve()` HTTP server.**\n\n`bun-route` leverages Bun.js's powerful `bun.serve` to deliver a fast, familiar, and reliable routing experience. It provides developers with an easy-to-use, Express-like API, tailored for high-performance applications built with Bun.js.\n\n*At the **time of `bun-route`'s creation**, Bun.js did not include a built-in router, so `bun-route` was designed as a lightweight, dependency-free solution to fill that gap.*\n\n# features\n\n## life improvement\n\n- **wildcards**: Can handle double wildcards (`**`) as any recursive path and \n  single wildcards (`*`) as any path part. *It also provides a path parameter string array\".*\n  If enabled, cookies can also automatically be set/unset to the response headers. \n- **static-serve**: Serves static files via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/static-serve.ts)).\n- **dump-router**: You can create a string router dump that lists the defined routes.\n  If you provide a bun server, it also adds a `server-is-running-on` message.\n- **basic-auth**: Protects the following via HTTP basic auth ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/basic-auth.ts)).\n- **cookie-handling**: Cookie parsing can be enabled via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/cookies.ts)).  \n- **redirect-handler**: You can redirect via the `ResponseBuilder` or\n  via a redirect middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/redirect.ts)).\n- **websocket-support**: Can handle websocket request via a middleware ([example](https://github.com/NobleMajo/bun-route/blob/main/examples/websocket.ts)).\n\n## performance\n\n- **non-async-first**: Tries to resolve a request in a non-async way until an async handler is hit.\n- **merged-routes**: If 2 or more routes are defined one after the other with the same method and path,\n  they will be merged into a single handler to avoid re-checking.\n- **method-enum**: You just write `GET`, but in the background it is converted to an enum.  \n  *This is for faster method comparison.*\n\n# usage\n\n## install\n\nInstall **typescript** source from GitHub:\n\n```sh\nbun i github:NobleMajo/bun-route\n```\n\nor compiled **javascript** from the npm registry:\n\n```sh\nnpm i bun-route\n```\n\n## import \n\n```ts\nimport { Router } from \"bun-route\";\n```\n\n## example\n\n```ts\nimport { Router } from \"bun-route\";\n\nconst router = new Router()\n\n// handles GET requests to /\nrouter.get(\"/\", (req, res) =\u003e {\n    res.send(\"Root request\")\n})\n\n// use the native bun.serve function the router as request handler\nconst server = Bun.serve({\n    fetch: router.handle,\n})\n\n// dumps router routes and server-is-running-on message\nconsole.info(router.dump(server))\n```\n\n# examples\n\nCheckout the bun-route [examples](https://github.com/NobleMajo/bun-route/tree/main/examples):\n- [simple example](https://github.com/NobleMajo/bun-route/blob/main/examples/simple.ts)\n- [static-serve example](https://github.com/NobleMajo/bun-route/blob/main/examples/static-serve.ts)\n- [websocket example](https://github.com/NobleMajo/bun-route/blob/main/examples/websocket.ts)\n- [redirect example](https://github.com/NobleMajo/bun-route/blob/main/examples/redirect.ts)\n- [cookies example](https://github.com/NobleMajo/bun-route/blob/main/examples/cookies.ts)\n- [basic auth example](https://github.com/NobleMajo/bun-route/blob/main/examples/basic-auth.ts)\n\nRun a example:\n```sh\ngit clone https://github.com/NobleMajo/bun-route.git\n\nbun run examples/simple.ts\n```\n\n# tests\n\nThe router has build-in tests.\n\n```ts\nbun test\n```\n\n# future features\nHere are some feature ideas for future development:\n- **CORS-support**: Configure CORS headers via a buildin middleware.\n- **router.serve**: Serve/listen function to start the server via the router (first parameter should be the bun.serve options without fetch).\n- **websocket**: Better websocket support with more origin request infos.\n\n# Contributing\nContributions to this project are welcome!  \nInterested users can refer to the guidelines provided in the [CONTRIBUTING.md](CONTRIBUTING.md) file to contribute to the project and help improve its functionality and features.\n\n# License\nThis project is licensed under the [MIT license](LICENSE), providing users with flexibility and freedom to use and modify the software according to their needs.\n\n# Disclaimer\nThis project is provided without warranties.  \nUsers are advised to review the accompanying license for more information on the terms of use and limitations of liability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoblemajo%2Fbun-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoblemajo%2Fbun-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoblemajo%2Fbun-route/lists"}