{"id":17349196,"url":"https://github.com/co2-git/web-rockets","last_synced_at":"2025-07-11T03:07:12.420Z","repository":{"id":68259692,"uuid":"51321218","full_name":"co2-git/web-rockets","owner":"co2-git","description":"Start/stop a socket.io server in a few lines. Useful for prototyping.","archived":false,"fork":false,"pushed_at":"2016-11-14T03:18:44.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T11:44:44.909Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/co2-git.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}},"created_at":"2016-02-08T19:31:16.000Z","updated_at":"2022-04-09T16:27:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ff0a41b-74b4-465a-a66a-836b8c494d1a","html_url":"https://github.com/co2-git/web-rockets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/co2-git/web-rockets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fweb-rockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fweb-rockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fweb-rockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fweb-rockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co2-git","download_url":"https://codeload.github.com/co2-git/web-rockets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fweb-rockets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264719240,"owners_count":23653542,"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":[],"created_at":"2024-10-15T16:55:01.473Z","updated_at":"2025-07-11T03:07:12.388Z","avatar_url":"https://github.com/co2-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"web-rockets\n===\n\nStart/stop and customize a socket.io server in a few lines. Useful for prototyping.\n\n# Install\n\n```bash\nnpm install web-rockets\n```\n\n# Usage\n\n```js\nimport WebRockets from 'web-rockets';\n\nnew WebRockets();\n```\n\nA Web Socket Server needs a HTTP server. We'll start one for you if you don't specify any.\n\n# Express integration\n\n```js\nimport http from 'http';\nimport express from 'express';\n\nconst httpServer = http.createServer(express());\n\nhttpServer.listen(() =\u003e new WebRockets(httpServer));\n```\n\n# Express emitter\n\n```js\nimport HTTPServer from 'express-emitter';\n\nconst http = new HTTPServer()\n  .on('listening', () =\u003e new WebRockets(http.server));\n```\n\n# Stop and restart\n\n```js\nconst webRockets = new WebRockets()\n  .stop()\n  .then(() =\u003e webRockets.start());\n```\n\n# Listeners\n\nYou can add or remove listeners like this:\n\n```js\nconst ping = socket =\u003e socket.emit('pong');\n\nnew WebRockets()\n  .listen('ping', ping)\n  .unlisten('ping', ping);\n```\n\n# Middleware\n\n```js\nnew WebRockets()\n  // the same way you would do with socket.io\n  .use((socket, next) =\u003e next());\n```\n\n# Authentification by cookie\n\nWe support authentication via cookie if you also install `web-rockets-cookie`.\n\n```js\nimport identifyByCookie from 'web-rockets-cookie';\n\nnew WebRockets()\n  .use(identifyByCookie(\n    cookieName, // String - name of the cookie,\n    true, // Boolean . true for secure cookies\n    (cookie, socket, next) =\u003e { /* ... */ } // what to do\n  ));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fweb-rockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco2-git%2Fweb-rockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fweb-rockets/lists"}