{"_id":"@socket.io/postgres-emitter","_rev":"3-4986b3fefbf0dbd22ba9f19ca436c546","name":"@socket.io/postgres-emitter","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@socket.io/postgres-emitter","version":"0.1.0","keywords":["socket.io","postgres","postgresql","emitter"],"license":"MIT","_id":"@socket.io/postgres-emitter@0.1.0","maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"homepage":"https://github.com/socketio/socket.io-postgres-emitter#readme","bugs":{"url":"https://github.com/socketio/socket.io-postgres-emitter/issues"},"dist":{"shasum":"f6f3d8b09a0532e37f158a19c874f0be3bb86774","tarball":"https://registry.npmjs.org/@socket.io/postgres-emitter/-/postgres-emitter-0.1.0.tgz","fileCount":8,"integrity":"sha512-14dPh2+mDRfIfZgTHi2BaxFpLRki1dBMwwPjtmJRlN+nIU4X5UyHGLHgsw2pevKt7hqc95q0DpL4dLQMxA1IwA==","signatures":[{"sig":"MEYCIQDYuP/ilvCe6JjB2xPmn4NAMuuvZFP16U7rIdppNHO2FwIhAMOWU0ysZpjM4BL2DBphfaEtz0z1YvtYFgjMYMPIIxcj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25335,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxvEPCRA9TVsSAnZWagAAVY4P/3VqayaAkdtsU1CSdpS3\n0XwRgC0yqHju1hc2Jnl+OQlcUxxgKzHe0/DrfdMC8BKRYEnb+zHtPrd6CVVz\nVITFRP3kJK/C/3K403a3B8DHOa/BmSBzdMOIjm9KzBPoNUZNYB/jP0yAj4FL\nUS/NHtgZXFEwRWN2Lh2zKeiFoSxDu37rkGgIjUNHx1YCHF8a6ZynMw2fESK4\n+TDf7UKAPzLcwiSBjO4tFqhSI0aqg8KQM3UgIphXrR/4c+EXk/k8+opDIC3i\nMAz+DZOKPRIV0pxkgSxLk1GqCpCj+8IassmntZ7rPPW8UIX+qNFfKY4r4KOP\n5oJYRqhrAy2jmZbQQWOY5lIsiiWzaaP1n6tfJdFVVuD8EL5SLaNR6CpuZk/D\n3Gxqq72eXtBT4V+LF4W6ymHaGBITn/IcNBIgat9lytt7gVfg57qiNbyr9pg4\n0ogPRglSYrn+DKOBFpKEhuO9p9xQ7VHkmU5+mHzTdUCfH0GH+eJnBFI6nRtL\nOiw5S0r6eIOJC+UCl2HOEW4OZJRLjWcVeyqlqABix8DHtmlEKBER9wEUSLOr\nrmds+m2Qkl2Rn2QGNOUvJl1Nto/fDO3mG3pxqZIYdatFlfapA2z0a6IOFTYY\n1121W5YDSO+EKPYwfg2adSAKoijAyTmvy2xqh3nAf1AbjECtQE8xGh1mOk9g\n4nYb\r\n=UMQm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"eb01ff5803a46457a6fb8c48e4ff145b7d4821a1","scripts":{"test":"npm run format:check && tsc && nyc mocha --require ts-node/register --timeout 5000 test/index.ts","prepack":"tsc","format:fix":"prettier --parser typescript --write 'lib/**/*.ts' 'test/**/*.ts'","format:check":"prettier --parser typescript --check 'lib/**/*.ts' 'test/**/*.ts'"},"_npmUser":{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"},"repository":{"url":"git+https://github.com/socketio/socket.io-postgres-emitter.git","type":"git"},"_npmVersion":"6.14.8","description":"The Socket.IO Postgres emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","directories":{},"_nodeVersion":"12.19.0","dependencies":{"debug":"~4.3.1","@msgpack/msgpack":"^2.7.0"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.6.0","nyc":"^15.1.0","mocha":"^8.3.2","ts-node":"^9.1.1","prettier":"^2.2.1","@types/pg":"^8.6.0","expect.js":"~0.3.1","socket.io":"^4.1.1","typescript":"^4.2.3","@types/node":"^14.14.35","@types/debug":"^4.1.5","@types/mocha":"^8.2.1","@types/expect.js":"^0.3.29","socket.io-client":"^4.1.1","@socket.io/postgres-adapter":"^0.1.0"},"_npmOperationalInternal":{"tmp":"tmp/postgres-emitter_0.1.0_1623650574798_0.0813033042103517","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@socket.io/postgres-emitter","version":"0.1.1","description":"The Socket.IO Postgres emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","license":"MIT","homepage":"https://github.com/socketio/socket.io/tree/main/packages/socket.io-postgres-emitter#readme","repository":{"type":"git","url":"git+https://github.com/socketio/socket.io.git"},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"compile":"rimraf ./dist && tsc","test":"npm run format:check && npm run compile && nyc mocha --require ts-node/register --timeout 5000 test/index.ts","format:check":"prettier --parser typescript --check 'lib/**/*.ts' 'test/**/*.ts'","format:fix":"prettier --parser typescript --write 'lib/**/*.ts' 'test/**/*.ts'","prepack":"npm run compile"},"dependencies":{"@msgpack/msgpack":"^2.7.0","debug":"~4.3.1"},"keywords":["socket.io","postgres","postgresql","emitter"],"_id":"@socket.io/postgres-emitter@0.1.1","gitHead":"ac3df9a747a73d92bd49d62b666ca175a9f9b2f1","bugs":{"url":"https://github.com/socketio/socket.io/issues"},"_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-9XYfp871EWLXoeJtzC9t+h9JIEVPKX1RhFsZlFagrAaaiFFhLcJKTi7e1lgWSY8jCZb4VGoboAG1RR7kCpZKCQ==","shasum":"c0329706120d17b6e30f4b24cdcb626f4cfd8aa0","tarball":"https://registry.npmjs.org/@socket.io/postgres-emitter/-/postgres-emitter-0.1.1.tgz","fileCount":7,"unpackedSize":25662,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@socket.io%2fpostgres-emitter@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH+HUBMYLFg33qxaJ6RQYaPvlDWhv+qkl3QQXH0IiSXhAiEAiazrG1ADgaszX9AwPOWVzg1c/71VxDAJzKP26KQxwf8="}]},"_npmUser":{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"},"directories":{},"maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/postgres-emitter_0.1.1_1757050771628_0.9087243171157684"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-14T06:02:54.798Z","modified":"2025-09-05T05:39:32.231Z","0.1.0":"2021-06-14T06:02:55.043Z","0.1.1":"2025-09-05T05:39:31.809Z"},"bugs":{"url":"https://github.com/socketio/socket.io/issues"},"license":"MIT","homepage":"https://github.com/socketio/socket.io/tree/main/packages/socket.io-postgres-emitter#readme","keywords":["socket.io","postgres","postgresql","emitter"],"repository":{"type":"git","url":"git+https://github.com/socketio/socket.io.git"},"description":"The Socket.IO Postgres emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process","maintainers":[{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"readme":"# Socket.IO Postgres emitter\n\nThe `@socket.io/postgres-emitter` package allows you to easily communicate with a group of Socket.IO servers from another Node.js process (server-side).\n\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"./assets/emitter_dark.png\">\n  <img alt=\"Diagram of Socket.IO packets forwarded through PostgreSQL\" src=\"./assets/emitter.png\">\n</picture>\n\nIt must be used in conjunction with [`@socket.io/postgres-adapter`](https://github.com/socketio/socket.io-postgres-adapter/).\n\nSupported features:\n\n- [broadcasting](https://socket.io/docs/v4/broadcasting-events/)\n- [utility methods](https://socket.io/docs/v4/server-instance/#Utility-methods)\n  - [`socketsJoin`](https://socket.io/docs/v4/server-instance/#socketsJoin)\n  - [`socketsLeave`](https://socket.io/docs/v4/server-instance/#socketsLeave)\n  - [`disconnectSockets`](https://socket.io/docs/v4/server-instance/#disconnectSockets)\n  - [`serverSideEmit`](https://socket.io/docs/v4/server-instance/#serverSideEmit)\n\nRelated packages:\n\n- Postgres adapter: https://github.com/socketio/socket.io-postgres-adapter/\n- Redis adapter: https://github.com/socketio/socket.io-redis-adapter/\n- Redis emitter: https://github.com/socketio/socket.io-redis-emitter/\n- MongoDB adapter: https://github.com/socketio/socket.io-mongo-adapter/\n- MongoDB emitter: https://github.com/socketio/socket.io-mongo-emitter/\n\n**Table of contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Known errors](#known-errors)\n- [License](#license)\n\n## Installation\n\n```\nnpm install @socket.io/postgres-emitter pg\n```\n\nFor TypeScript users, you might also need `@types/pg`.\n\n## Usage\n\n```js\nconst { Emitter } = require(\"@socket.io/postgres-emitter\");\nconst { Pool } = require(\"pg\");\n\nconst pool = new Pool({\n  user: \"postgres\",\n  host: \"localhost\",\n  database: \"postgres\",\n  password: \"changeit\",\n  port: 5432,\n});\n\nconst io = new Emitter(pool);\n\nsetInterval(() => {\n  io.emit(\"ping\", new Date());\n}, 1000);\n```\n\n## API\n\n### `Emitter(pool[, nsp][, opts])`\n\n```js\nconst io = new Emitter(pool);\n```\n\nThe `pool` argument is a [Pool object](https://node-postgres.com/api/pool) from the `pg` package.\n\n### `Emitter#to(room:string):BroadcastOperator`\n### `Emitter#in(room:string):BroadcastOperator`\n\nSpecifies a specific `room` that you want to emit to.\n\n```js\nio.to(\"room1\").emit(\"hello\");\n```\n\n### `Emitter#except(room:string):BroadcastOperator`\n\nSpecifies a specific `room` that you want to exclude from broadcasting.\n\n```js\nio.except(\"room2\").emit(\"hello\");\n```\n\n### `Emitter#of(namespace:string):Emitter`\n\nSpecifies a specific namespace that you want to emit to.\n\n```js\nconst customNamespace = io.of(\"/custom\");\n\ncustomNamespace.emit(\"hello\");\n```\n\n### `Emitter#socketsJoin(rooms:string|string[])`\n\nMakes the matching socket instances join the specified rooms:\n\n```js\n// make all Socket instances join the \"room1\" room\nio.socketsJoin(\"room1\");\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room join the \"room2\" room\nio.of(\"/admin\").in(\"room1\").socketsJoin(\"room2\");\n```\n\n### `Emitter#socketsLeave(rooms:string|string[])`\n\nMakes the matching socket instances leave the specified rooms:\n\n```js\n// make all Socket instances leave the \"room1\" room\nio.socketsLeave(\"room1\");\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room leave the \"room2\" room\nio.of(\"/admin\").in(\"room1\").socketsLeave(\"room2\");\n```\n\n### `Emitter#disconnectSockets(close:boolean)`\n\nMakes the matching socket instances disconnect:\n\n```js\n// make all Socket instances disconnect\nio.disconnectSockets();\n\n// make all Socket instances of the \"admin\" namespace in the \"room1\" room disconnect\nio.of(\"/admin\").in(\"room1\").disconnectSockets();\n\n// this also works with a single socket ID\nio.of(\"/admin\").in(theSocketId).disconnectSockets();\n```\n\n### `Emitter#serverSideEmit(ev:string[,...args:any[]])`\n\nEmits an event that will be received by each Socket.IO server of the cluster.\n\n```js\nio.serverSideEmit(\"ping\");\n```\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}