{"id":17972659,"url":"https://github.com/vasanthv/unsocket","last_synced_at":"2025-04-03T23:12:47.810Z","repository":{"id":196288977,"uuid":"694901250","full_name":"vasanthv/unsocket","owner":"vasanthv","description":"A HTTP-based pub-sub service to replace websockets","archived":false,"fork":false,"pushed_at":"2023-09-29T13:31:30.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-17T01:23:05.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://unsocket.vercel.app","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/vasanthv.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}},"created_at":"2023-09-21T23:41:47.000Z","updated_at":"2023-09-28T22:52:03.000Z","dependencies_parsed_at":"2023-09-29T01:13:58.691Z","dependency_job_id":null,"html_url":"https://github.com/vasanthv/unsocket","commit_stats":null,"previous_names":["vasanthv/pinggy","vasanthv/unsocket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Funsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Funsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Funsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Funsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasanthv","download_url":"https://codeload.github.com/vasanthv/unsocket/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237938100,"owners_count":19390555,"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-29T16:24:33.837Z","updated_at":"2025-02-09T10:45:36.632Z","avatar_url":"https://github.com/vasanthv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unsocket\n\n## A HTTP-based pub-sub service to replace websockets using Express.js\n\nUnsocket uses HTTP POST to post events and Server-Sent Events (SSE) to subscribe to events. So, no third-party client is needed, all major browsers support this protocol.\n\n### Subscribe to a channel\n\nUnsocket uses channels to differentiate multiple streams. You can use SSE as below to subscribe to any channel.\n\n```js\nconst events = new EventSource(\"/test-channel\");\n```\n\nHere `test-channel` is the channel name. A channel name should be lowercase alphanumeric characters up to 40 characters long.\n\n### Listening to events\n\nYou can listen to all messages in a channel or only to specific events as follows.\n\n```js\n// Listens to all messages in the channel\nevents.onmessage((e) =\u003e console.log(e));\n\n// Listens to only chat events in the channel\nevents.addEventListener(\"chat\", (e) =\u003e console.log(e));\n```\n\n### Posting to channel\n\nUse simple HTTP POST for emitting events to all the subscribers. Currently, only plain text body is supported.\n\n```js\nfetch(\"/test-channel\", {\n\tmethod: \"POST\",\n\tmode: \"cors\",\n\tcache: \"no-cache\",\n\theaders: { \"Content-Type\": \"text/plain\" },\n\tbody: \"Hello World\",\n});\n```\n\n### How to run locally\n\nFork this repo and then clone it:\n\n```\ngit clone https://github.com/\u003cyour_name\u003e/unsocket.git\n```\n\n```\nnpm install\n```\n\nThen just run\n\n```\nnpm start\n```\n\nto start the development server on port `3000`. Your jsonbox instance will be running on `http://localhost:3000`.\n\n### LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasanthv%2Funsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasanthv%2Funsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasanthv%2Funsocket/lists"}