{"id":13623330,"url":"https://github.com/mafintosh/browser-server","last_synced_at":"2025-08-05T08:15:32.599Z","repository":{"id":65994634,"uuid":"91696486","full_name":"mafintosh/browser-server","owner":"mafintosh","description":"A HTTP \"server\" in the browser that uses a service worker to allow you to easily send back your own stream of data.","archived":false,"fork":false,"pushed_at":"2018-10-07T03:15:10.000Z","size":9,"stargazers_count":187,"open_issues_count":5,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-08T17:06:25.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/mafintosh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2017-05-18T13:27:49.000Z","updated_at":"2024-10-27T20:29:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"69c91dd5-4e01-4a3b-b6d1-5887f5eeef60","html_url":"https://github.com/mafintosh/browser-server","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"38e68b602137bf671fe7e60fc7e342b896bb3061"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mafintosh/browser-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fbrowser-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fbrowser-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fbrowser-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fbrowser-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafintosh","download_url":"https://codeload.github.com/mafintosh/browser-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Fbrowser-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268859139,"owners_count":24318879,"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-08-05T02:00:12.334Z","response_time":2576,"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-08-01T21:01:30.459Z","updated_at":"2025-08-05T08:15:32.559Z","avatar_url":"https://github.com/mafintosh.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# browser-server\n\nA HTTP \"server\" in the browser that uses a service worker to allow you to easily send back your own stream of data.\n\n```\nnpm install browser-server\n```\n\n## Usage\n\nFirst generate the service worker, using the browser-server command line tool\n\n```\nnpm install -g browser-server\n# /demo is the prefix you want to intercept\nbrowser-server /demo \u003e worker.js\n```\n\nThen create a simple app and browserify it\n\n``` js\nvar createServer = require('browser-server')\nvar server = createServer()\n\nserver.on('request', function (req, res) {\n  console.log('intercepting request', req)\n  res.end('hello world')\n})\n\nserver.on('ready', function () {\n  fetch('/demo/test.txt').then(function (r) {\n    return r.text()\n  }).then(function (txt) {\n    console.log('fetch returned', txt)\n  })\n})\n```\n\nThen browserify this app\n\n```\nbrowserify app.js \u003e bundle.js\n```\n\nAnd make a index.html page like this\n\n\n``` html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nMake sure the worker.js file is also stored in the same folder.\n\nNow serve the folder using a http server, fx\n\n```\nnpm install -g http-server\nhttp-server .\n```\n\nNow if you open index.html you should see the server intercepting the request and returning hello world.\n\nWorks for all http apis, including video/audio tags!\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fbrowser-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafintosh%2Fbrowser-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Fbrowser-server/lists"}