{"id":30460880,"url":"https://github.com/restatedev/pubsub","last_synced_at":"2025-08-23T20:34:55.164Z","repository":{"id":308750268,"uuid":"1029232698","full_name":"restatedev/pubsub","owner":"restatedev","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-07T16:14:46.000Z","size":350,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-07T18:22:05.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/restatedev.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,"zenodo":null}},"created_at":"2025-07-30T18:09:31.000Z","updated_at":"2025-08-01T16:06:44.000Z","dependencies_parsed_at":"2025-08-07T18:37:36.839Z","dependency_job_id":null,"html_url":"https://github.com/restatedev/pubsub","commit_stats":null,"previous_names":["restatedev/pubsub"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/restatedev/pubsub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fpubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fpubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fpubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fpubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/restatedev","download_url":"https://codeload.github.com/restatedev/pubsub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restatedev%2Fpubsub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271767989,"owners_count":24817592,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-23T20:34:49.800Z","updated_at":"2025-08-23T20:34:55.127Z","avatar_url":"https://github.com/restatedev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 🚀 Quick Start\n\n### Create a new project\n\n```sh\nbun init .\nbun add \"@restatedev/pubsub\"\nbun add \"@restatedev/restate-sdk\"\n```\n\n### Replace the content of index.ts\n\n```ts\nimport { createPubsubObject } from \"@restatedev/pubsub\";\nimport { serve } from \"@restatedev/restate-sdk\";\n\nconst pubsub = createPubsubObject(\"sessions\", {});\n\nserve({\n  services: [pubsub],\n});\n```\n\n### Start the service\n\n```sh\nbun run index.ts\n```\n\n### After successfully registering this with the restate server, you can produce and consume from any topic, by interacting with the 'sessions' virtual object.\n\nFor example:\n\n```sh\ncurl --request POST \\\n  --url http://127.0.0.1:8080/sessions/123/publish \\\n  --header 'Accept: application/json' \\\n  --header 'Content-Type: application/json' \\\n  --data '\"hello world\"'\n```\n\nOr pull for new messages\n\n```sh\ncurl --request POST \\\n  --url http://127.0.0.1:8080/sessions/123/pull \\\n  --header 'Accept: application/json' \\\n  --header 'Content-Type: application/json' \\\n  --data '{ \"offset\" : 0 }'\n```\n\nOr use the pubsub client to consume an SSE stream:\n\n```sh\nbun add \"@restatedev/pubsub-client\"\n```\n\n```typescript\n// sse.ts\n\nimport { createPubsubClient } from \"@restatedev/pubsub-client\";\n\nconst pubsub = createPubsubClient({\n  ingressUrl: \"http://localhost:8080\",\n  name: \"sessions\", // \u003c-- same as your pubsub virtual object above.\n});\n\nBun.serve({\n  port: 3000,\n  fetch(request) {\n    const stream = pubsub.sse({ topic: \"123\" });\n    return new Response(stream, {\n      headers: {\n        \"Content-Type\": \"text/event-stream\",\n        \"Cache-Control\": \"no-cache\",\n        Connection: \"keep-alive\",\n      },\n    });\n  },\n});\n```\n\nAnd then:\n\n```sh\ncurl http://localhost:3000/sse\nevent: ping\ndata: \"hello\"\n\ndata: \"world\"\n\ndata: \"bla\"\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestatedev%2Fpubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frestatedev%2Fpubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestatedev%2Fpubsub/lists"}