{"id":16228703,"url":"https://github.com/wsmd/ws-multipath","last_synced_at":"2025-03-19T13:31:28.871Z","repository":{"id":57399940,"uuid":"120711633","full_name":"wsmd/ws-multipath","owner":"wsmd","description":"🛣 Serve multiple WebSocket endpoints using one shared server","archived":false,"fork":false,"pushed_at":"2024-01-22T06:41:47.000Z","size":47,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T19:01:03.247Z","etag":null,"topics":["http-server","javascript","multipath","node","nodejs","realtime","routing","websocket-server","websockets"],"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/wsmd.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-08T04:39:18.000Z","updated_at":"2023-06-28T16:11:09.000Z","dependencies_parsed_at":"2024-10-27T20:53:48.151Z","dependency_job_id":null,"html_url":"https://github.com/wsmd/ws-multipath","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"d2744a500a500f8a33e8229b83b9c622a93484a2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fws-multipath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fws-multipath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fws-multipath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fws-multipath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wsmd","download_url":"https://codeload.github.com/wsmd/ws-multipath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243992426,"owners_count":20380201,"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":["http-server","javascript","multipath","node","nodejs","realtime","routing","websocket-server","websockets"],"created_at":"2024-10-10T12:56:14.629Z","updated_at":"2025-03-19T13:31:28.628Z","avatar_url":"https://github.com/wsmd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/wsmd/ws-multipath.svg?branch=master)](https://travis-ci.org/wsmd/ws-multipath)\n[![Coverage Status](https://coveralls.io/repos/github/wsmd/ws-multipath/badge.svg?branch=master)](https://coveralls.io/github/wsmd/ws-multipath?branch=master)\n[![License](https://img.shields.io/github/license/wsmd/ws-multipath.svg)](https://github.com/wsmd/ws-multipath/blob/master/LICENSE)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/2100222/36067365-6f2f344c-0e89-11e8-87fa-94513973b6d3.png\" width=\"88\" alt=\"logo\" /\u003e\n\n# ws-multipath\n\n`ws-multipath` is a wrapper around [`websockets/ws`](https://github.com/websockets/ws/) that provides the ability to attach multiple WebSocket servers to one shared HTTP server to handle multiple paths.\n\n## Why?\n\nHave you ever wanted to serve multiple WebSocket endpoints using a single port/server. You might have tried something that looked a little bit like this:\n\n```js\nconst { Server } = require('ws');\n\nconst PORT = 1234;\n\nconst server1 = new Server({ port: PORT, path:'/notifications' });\nconst server2 = new Server({ port: PORT, path:'/messages' });\n```\n\nSoon after, you realize that it's not possible. Not easily, at least.\n\nHaving multiple WebSocket servers on the same port can be a messy process. So I decided to write `ws-multipath` in hopes of simplifying this task.\n\n## How?\n\nIn order to have multiple WebSockets server running on the same port, a developer would have to create multiple \"serverless\" `WebSocket.Server`s (using the `noServer` option) and utilize one shared HTTP server that delegates requests to the proper WebSocket server.\n\nSounds complicated, right? That's all what `ws-multipath` does!\n\n## Example\n\n```js\nconst MultipathServer = require('ws-multipath');\n\nconst server = new MultipathServer({ port: 1234 });\n\nconst foo = server.createHandler({ path: '/foo' });\nconst bar = server.createHandler({ path: '/bar' });\n\n// handle sockets connecting to ws://localhost:1234/foo\nfoo.on('connection', (ws) =\u003e {\n  ws.send('hello from /foo!');\n});\n\n// handle sockets connecting to ws://localhost:1234/bar\nbar.on('connection', (ws) =\u003e {\n  ws.send('hello from /bar!');\n});\n```\n\n## Documentation\n\n\u003e _Please note that this is experimental and under active development. Therefore, it may have numerous bugs, and the API is subject to change._\n\nSee [`/docs/api.md`](./docs/api.md) for full API documentation.\n\n## Installation\n\nTo install `ws-multipath`, you must have `ws` installed as well.\n\n```bash\n# ws is a peer-dependency of ws-multipath\n\n# using npm\nnpm install --save ws ws-multipath\n\n# using yarn\nyarn add ws ws-multipath\n```\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsmd%2Fws-multipath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwsmd%2Fws-multipath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsmd%2Fws-multipath/lists"}