{"id":17686505,"url":"https://github.com/psi-4ward/express-websocket","last_synced_at":"2025-07-07T07:33:41.805Z","repository":{"id":26416709,"uuid":"29866909","full_name":"psi-4ward/express-websocket","owner":"psi-4ward","description":"Access express routes through websocket requests","archived":false,"fork":false,"pushed_at":"2015-01-28T11:16:03.000Z","size":132,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-07T05:18:02.924Z","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/psi-4ward.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}},"created_at":"2015-01-26T15:24:29.000Z","updated_at":"2016-03-30T12:51:21.000Z","dependencies_parsed_at":"2022-09-20T12:42:03.872Z","dependency_job_id":null,"html_url":"https://github.com/psi-4ward/express-websocket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/psi-4ward/express-websocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psi-4ward%2Fexpress-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psi-4ward%2Fexpress-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psi-4ward%2Fexpress-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psi-4ward%2Fexpress-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psi-4ward","download_url":"https://codeload.github.com/psi-4ward/express-websocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psi-4ward%2Fexpress-websocket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264034848,"owners_count":23547289,"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-24T10:45:04.835Z","updated_at":"2025-07-07T07:33:41.785Z","avatar_url":"https://github.com/psi-4ward.png","language":"JavaScript","readme":"# express-websocket\n\nAccess express routes using a [Primus](https://github.com/primus/primus) websocket connection.\n\n\n### Installation\n```\nnpm install psi-4ward/express-websocket\n```\n\n\n### Server\n```javascript\n// Init express\nvar app = require('express')();\napp.get('/hello', function(req, res) {\n  // identify / access websocket within routes / middlewares\n  if(req.isWebsocket) {\n    console.log('request from spark id', req.spark.id);\n  }\n\n  res.send('Hello World!')\n});\nvar httpServer = app.listen(3000);\n\n// attach express-websocket\nvar expressWebsocket = require('express-websocket');\nexpressWebsocket(app, httpServer, { /* primus options */ });\n```\n\nIn addition to primus options you can pass a `beforeExpress: function(req, res, cb) {...} ` property to hook in right befor the\n data goes out to express router. \n\nStart your app with `DEBUG=express-websocket node app.js` to enable debug output\n\n### Client\n```html\n// primus serves its client lib via /primus/primus.js\n\u003cscript src=\"http://localhost:3000/primus/primus.js\"\u003e\u003c/script\u003e\n\n\nvar primus = Primus('http://localhost:3000');\nvar jsonWebRequest = {\n  type: 'json-web-request',\n  method: 'GET',\n  url: '/hello'\n};\nprimus.writeAndWait(jsonWebRequest,  console.info.bind(console));\n```\n\n## License\n\n  [MIT](LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsi-4ward%2Fexpress-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsi-4ward%2Fexpress-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsi-4ward%2Fexpress-websocket/lists"}