{"id":20951493,"url":"https://github.com/wll8/express-ws","last_synced_at":"2025-06-17T10:10:17.246Z","repository":{"id":37350775,"uuid":"493952412","full_name":"wll8/express-ws","owner":"wll8","description":"Quickly implement websocket API in express.","archived":false,"fork":false,"pushed_at":"2025-04-19T11:55:52.000Z","size":64,"stargazers_count":25,"open_issues_count":5,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-09T11:58:32.753Z","etag":null,"topics":["express","websocket"],"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/wll8.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-19T06:44:41.000Z","updated_at":"2025-04-19T11:55:56.000Z","dependencies_parsed_at":"2024-06-19T01:38:30.289Z","dependency_job_id":"7d59569f-2c2f-44a7-88fd-c6bcd4163495","html_url":"https://github.com/wll8/express-ws","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"ddf04e09cafdfd0645fb8701014a267a0df3f5cb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wll8/express-ws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wll8%2Fexpress-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wll8%2Fexpress-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wll8%2Fexpress-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wll8%2Fexpress-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wll8","download_url":"https://codeload.github.com/wll8/express-ws/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wll8%2Fexpress-ws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260336343,"owners_count":22993740,"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":["express","websocket"],"created_at":"2024-11-19T00:59:20.203Z","updated_at":"2025-06-17T10:10:12.233Z","avatar_url":"https://github.com/wll8.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-ws\nQuickly implement websocket API in express.\n\nThere are some issues with [HenningM/express-ws](https://github.com/HenningM/express-ws), the author has not been active for more than 1 year. So I created this project.\n\nThis repository is not intended to be a replacement, but to provide options to solve a problem, you can view the [differences](#differences) here.\n\nIt may provide a solution for the following problems:\n- https://github.com/HenningM/express-ws/issues/157\n- https://github.com/HenningM/express-ws/issues/126\n- https://github.com/HenningM/express-ws/issues/52\n\n## Features\n- [x] Use directly from app.ws\n- [x] http and ws of the same route can exist at the same time\n- [x] Support dynamic routing\n- [x] Support reading params, query parameters\n- [x] Support Typescript\n\n## how to use\n\n``` sh\nnpm i @wll8/express-ws\n```\n\n``` js\nconst express = require(`express`)\nconst expressWs = require(`@wll8/express-ws`)\nconst {app, wsRoute} = expressWs(express())\n\napp.ws(`/abc`, (ws, req) =\u003e {\n  // const {params, query} = req\n  ws.send(`abc`)\n})\napp.get(`/abc`, (req, res) =\u003e {\n  res.json(`abc`)\n})\n\napp.listen(3040)\n```\n\n- For more examples see the file: [test.js](https://github.com/wll8/express-ws/blob/ad35c6156aed4f8d195214784ad903f22ce84536/test/index.test.ts#L15)\n- dependencies\n  ```\n  \"path-to-regexp\": \"0.1.7\",\n  \"ws\": \"7.5.5\"\n  ```\n## differences\n\n**Initialization**\n| HenningM                        | wll8                              | Remark                                          |\n| ------------------------------- | --------------------------------- | ----------------------------------------------- |\n| expressWs(app)                  | expressWs(app)                    | express instance                                |\n| expressWs(app, server)          | expressWs({app, server})          | http.createServer(app)                          |\n| expressWs(app, server, options) | expressWs({app, server, options}) | Other configuration                             |\n| options.leaveRouterUntouched    | ---                               | wll8: No                                        |\n| options.wsOptions               | options.ws                        | wll8: initialization parameters for each ws api |\n\n**return value**\n| HenningM           | wll8                 | Remark                                                                                                                     |\n| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------- |\n| wsInstance.app     | wsInstance.app       | wll8: same as app                                                                                                          |\n| wsInstance.getWss  | ---                  | wll8: Get from [wsRoute](https://github.com/wll8/express-ws/blob/ad35c6156aed4f8d195214784ad903f22ce84536/src/type.ts#L25) |\n| wsInstance.applyTo | ---                  | wll8: No                                                                                                                   |\n| ---                | wsInstance.wsRoute[] | [{route, wss, mid}](https://github.com/wll8/express-ws/blob/ad35c6156aed4f8d195214784ad903f22ce84536/src/type.ts#L25), For example wss.clients can get all connected clients      |\n\n**Parse the request**\n| HenningM | wll8       | Remark               |\n| -------- | ---------- | -------------------- |\n| ---      | req.params | Parameters in routes |\n| ---      | req.query  | query parameter      |\n\n## License\n[MIT](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2022-present, wll8","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwll8%2Fexpress-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwll8%2Fexpress-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwll8%2Fexpress-ws/lists"}