{"id":15101824,"url":"https://github.com/mia-z/buxt","last_synced_at":"2025-09-27T00:30:41.253Z","repository":{"id":62717801,"uuid":"561280809","full_name":"mia-z/buxt","owner":"mia-z","description":"HTTP/REST server for Bun that uses filesystem based routing","archived":true,"fork":false,"pushed_at":"2022-11-10T14:19:13.000Z","size":114,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-24T13:17:57.148Z","etag":null,"topics":["bun","bunjs","rest","rest-api","routing","typescript"],"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/mia-z.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}},"created_at":"2022-11-03T10:59:49.000Z","updated_at":"2023-09-30T11:42:55.000Z","dependencies_parsed_at":"2023-01-22T18:00:10.966Z","dependency_job_id":null,"html_url":"https://github.com/mia-z/buxt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mia-z%2Fbuxt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mia-z%2Fbuxt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mia-z%2Fbuxt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mia-z%2Fbuxt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mia-z","download_url":"https://codeload.github.com/mia-z/buxt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219871828,"owners_count":16554457,"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","bunjs","rest","rest-api","routing","typescript"],"created_at":"2024-09-25T18:41:20.150Z","updated_at":"2025-09-27T00:30:40.913Z","avatar_url":"https://github.com/mia-z.png","language":"TypeScript","funding_links":[],"categories":["Extensions"],"sub_categories":["Frameworks"],"readme":"\u003cp align=\"center\"\u003e\n\u003c!-- \u003cimg src=\"https://github.com/mia-z/buxt/actions/workflows/main.js.yml/badge.svg\" /\u003e --\u003e\n\u003cimg src=https://img.shields.io/github/package-json/v/mia-z/buxt /\u003e\n\u003cimg src=https://img.shields.io/github/commit-activity/w/mia-z/buxt /\u003e\n\u003cimg src=\"https://img.shields.io/codecov/c/github/mia-z/buxt\" /\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./.gitfiles/buxt-logo.png\"\u003e\n \n\u003ch3 align=\"center\"\u003e\u003cb\u003eLightweight filesystem-based router for creating REST APIs.\u003c/b\u003e\n\n---\n\n## \u003cp align=\"center\"\u003e **Note**\n\n\u003cp align=\"center\"\u003e This project is currently very early development, and I wouldn't recommend it for production. Feel free to use it as you like and if you find any problems then submit an issue via github issues tab.\n\n---\n\n## \u003cp align=\"center\"\u003e Features/Roadmap\n\n- [x] Nested routing\n- [x] Route parameters\n- [ ] Catch-all routes on same level as named routes\n- [x] Implement response handling logic fully\n- [ ] Middleware\n- [x] CORS solution\n- [ ] Advanced Logging\n- [ ] Authentication\n- [ ] Websockets\n- [ ] ESLint plugin\n---\n\n## \u003cb\u003eInstallation\u003c/b\u003e\n`bun a buxt`\n\n## \u003cb\u003eGetting started\u003c/b\u003e\nStarting a basic server with the default values\n\n``` typescript\n//index.ts\nimport CreateServer from \"buxt\";\n\nawait CreateServer(3000).then(s =\u003e s.listen());\n\n//routes/example_endpoint.ts\nimport type { BuxtRequest, BuxtResponse } from \"buxt\"; //typings arent required, but useful!\n\nexport default async function(req: BuxtRequest, res: BuxtResponse) {\n    res.send(\"Hello!\");\n}\n```\nThats it!\n\n---\n\n## \u003cb\u003eUsage\u003c/b\u003e\n\nBy default, the app will search for exported functions under \u003cb\u003e\\\u003cproject-root\u003e/routes\u003c/b\u003e and \u003cb\u003e\\\u003cproject-root\u003e/src/routes\u003c/b\u003e, unless specified when creating the server.\n\nAside from the previous example, there are three other ways of creating and starting a buxt server:\n\n\n### \u003cb\u003e\u003cu\u003eCreate a server using port 3000 with default route root\u003c/u\u003e\u003c/b\u003e\n``` typescript\n//index.ts\nimport CreateServer from \"buxt\";\n\nconst server = await CreateServer(3000);\nawait server.listen();\n```\n\n### \u003cu\u003e\u003cb\u003eCreate a server using port 3000 and a custom root route path\u003c/b\u003e\u003c/u\u003e\n\n``` typescript\n//index.ts\nimport CreateServer from \"buxt\";\n\nconst server = await CreateServer(3000, \"src/api\");\nawait server.listen();\n```\n\n### \u003cu\u003e\u003cb\u003eCreate a server with config object\u003c/u\u003e\u003c/b\u003e\n\n``` typescript\n//index.ts\nimport CreateServer from \"buxt\";\n\nconst server = await CreateServer({\n    port: 3000,\n    routeRoot: \"api\",\n    cors: true,\n    corsConfig: {\n        origins: [ \"*\" ]\n    }\n});\nawait server.listen();\n```\n\n### Definitions for config\n\n``` typescript\ntype BuxtConfig = {\n    port: number,\n    routeRoot: string,\n    cors?: boolean = false,\n    corsConfig?: CorsConfig = null\n}\n\ntype CorsConfig = {\n    origins: string[],\n    allowedMethods?: HttpMethod[] = [\"GET\", \"OPTIONS\", \"POST\"]\n}\n\ntype HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\" | \"PATCH\";\n\n```\n\n### \u003cu\u003e\u003cb\u003eRoute parameters\u003c/b\u003e\u003c/u\u003e\nRoute parameters work like they do in Next.js - they're denoted by a variable name surrounded by square brackets, eg: routes/user/[user].ts\n\nThey can then be accessed on the BuxtRequest object under `req.routeParameters.{variable_name}`\n``` typescript\n//routes/user/[user].ts\nimport type { BuxtRequest, BuxtResponse } from \"buxt\";\n\nexport default async function(req: BuxtRequest, res: BuxtResponse) {\n    res.send(\"Hello \" + req.routeParameters.user);\n}\n```\n\n### \u003cu\u003e\u003cb\u003eEnabling Cors\u003c/b\u003e\u003c/u\u003e\nYou must create a server using a config object to enable cors responses.\n\n``` typescript\n//index.ts\nimport CreateServer from \"buxt\";\n\nconst server = await CreateServer({\n    port: 3000,\n    routeRoot: \"api\",\n    cors: true,\n    corsConfig: {\n        origins: [ \"localhost:3000\", \"localhost:3001\", \"https://miaz.xyz/\", \"http://miaz.xyz\" ],\n        allowedMethods: [ \"GET\", \"POST\", \"OPTIONS\", \"PUT\", \"DELETE\"]\n    }\n});\n```\n\nFirstly, make sure the cors key is set to `true`, then pass in a `CorsConfig` object. The `CorsConfig`'s `origins` key cannot be null. If you're allowing all origins then simply make it a single item array with `[\"*\"]`.\n\n\u003cb\u003eReminder\u003c/b\u003e that you cannot combine wildcard routes and non-wildcard routes; if you attempt to do this then it  will throw an error.\n\n---\n###### Big thanks to \u003ca href=\"https://github.com/lau1944\"\u003elau1994\u003c/a\u003e and their project \u003ca href=\"https://github.com/lau1944/bunrest\"\u003eBunrest\u003c/a\u003e (really nice express-like server built for Bun) which has helped me a lot getting this project started.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmia-z%2Fbuxt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmia-z%2Fbuxt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmia-z%2Fbuxt/lists"}