{"id":23705517,"url":"https://github.com/datkat21/bun-silly-web-server","last_synced_at":"2025-10-11T19:39:27.977Z","repository":{"id":193616428,"uuid":"689176329","full_name":"datkat21/bun-silly-web-server","owner":"datkat21","description":"simple and minimal server library for bun.js?","archived":false,"fork":false,"pushed_at":"2023-09-09T02:27:08.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T00:32:15.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/datkat21.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}},"created_at":"2023-09-09T02:15:18.000Z","updated_at":"2023-09-09T02:17:02.000Z","dependencies_parsed_at":"2023-09-09T03:52:25.120Z","dependency_job_id":null,"html_url":"https://github.com/datkat21/bun-silly-web-server","commit_stats":null,"previous_names":["datkat21/bun-silly-web-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/datkat21/bun-silly-web-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datkat21%2Fbun-silly-web-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datkat21%2Fbun-silly-web-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datkat21%2Fbun-silly-web-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datkat21%2Fbun-silly-web-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datkat21","download_url":"https://codeload.github.com/datkat21/bun-silly-web-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datkat21%2Fbun-silly-web-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008427,"owners_count":26084460,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-30T14:46:55.037Z","updated_at":"2025-10-11T19:39:27.943Z","avatar_url":"https://github.com/datkat21.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# silly-web-server\n\nSilly web server for Bun.js. :P \nThis little thing extends `Bun.serve()` and creates a simple wrapper with useful features such as a public directory, websocket support built-in, etc.\n\n## Usage\n\nThis isn't exactly a library (yet) so you'll have to copy the files from `handlers` into your project.\n\nHere are some server examples:\n\n**Basic HTTP server**\n```ts\nimport { requestHandler } from \"./handlers/requestHandler\";\nimport { ReqHandlerType, makeServer } from \"./handlers/serverConstructor\";\n\nconst server = makeServer({\n  // Set up the server basics\n  port: 3000,\n  publicFolderPath: \"./public\",\n\n  // Set up the request handler\n  requestHandler,\n  requestHandlerType: ReqHandlerType.UrlOnly\n});\n\nconsole.log(`Listening on localhost:${server.port}`);\n```\n\n**Basic websocket server**\n```ts\nimport { requestHandler } from \"./handlers/requestHandler\";\nimport { ReqHandlerType, makeServer } from \"./handlers/serverConstructor\";\n\nconst server = makeServer({\n  // Set up the server basics\n  port: 3000,\n  publicFolderPath: \"./public\",\n\n  // Set up the request handler\n  requestHandler,\n  requestHandlerType: ReqHandlerType.UrlAndWs,\n\n  // Instance of WebSocketHandler\n  websocketConfig: {\n    message(ws, message) {\n      console.log(`${ws.data} said: ${message}`);\n    },\n    // . . . (open, close, ping, pong, etc.)\n  },\n  // Also see websocketHandler to set custom `ws.data`.\n});\n\nconsole.log(`Listening on localhost:${server.port}`);\n```\n\n## Setup\n\nTo install dependencies:\n\n```bash\nbun install\n```\n\nTo run:\n\n```bash\nbun run index.ts\n```\n\nThis project was created using `bun init` in bun v1.0.0. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatkat21%2Fbun-silly-web-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatkat21%2Fbun-silly-web-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatkat21%2Fbun-silly-web-server/lists"}