{"id":26851248,"url":"https://github.com/muhammad-magdi/pgmq-js","last_synced_at":"2025-07-30T01:33:49.537Z","repository":{"id":216776431,"uuid":"741198141","full_name":"Muhammad-Magdi/pgmq-js","owner":"Muhammad-Magdi","description":"Postgres Message Queue (PGMQ) JavaScript Client Library","archived":false,"fork":false,"pushed_at":"2024-09-21T01:08:00.000Z","size":138,"stargazers_count":67,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T16:21:43.207Z","etag":null,"topics":["javascript","message-queue","node","npm-package","pgmq","postgres","postgresql","postgresql-extension","queues","typesc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Muhammad-Magdi.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}},"created_at":"2024-01-09T22:37:10.000Z","updated_at":"2025-04-12T00:32:52.000Z","dependencies_parsed_at":"2024-01-12T19:47:29.617Z","dependency_job_id":"09df49be-f01d-480f-9fff-3be0343897b2","html_url":"https://github.com/Muhammad-Magdi/pgmq-js","commit_stats":null,"previous_names":["muhammad-magdi/pgmq-js"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Muhammad-Magdi%2Fpgmq-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Muhammad-Magdi%2Fpgmq-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Muhammad-Magdi%2Fpgmq-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Muhammad-Magdi%2Fpgmq-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Muhammad-Magdi","download_url":"https://codeload.github.com/Muhammad-Magdi/pgmq-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252531882,"owners_count":21763293,"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":["javascript","message-queue","node","npm-package","pgmq","postgres","postgresql","postgresql-extension","queues","typesc"],"created_at":"2025-03-30T22:19:13.328Z","updated_at":"2025-05-05T16:21:44.517Z","avatar_url":"https://github.com/Muhammad-Magdi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgmq-js\n\nPostgres Message Queue (PGMQ) JavaScript Client Library\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pgmq-js\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/pgmq-js\" alt=\"version\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pgmq-js\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dw/pgmq-js\" alt=\"weekly downloads\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Muhammad-Magdi/pgmq-js/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/pgmq-js\" alt=\"license\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/Muhammad-Magdi/pgmq-js\" \u003e \n    \u003cimg src=\"https://codecov.io/gh/Muhammad-Magdi/pgmq-js/graph/badge.svg?token=ZOC1HSGGC7\"/\u003e \n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\nAs always:\n\n```bash\nnpm i pgmq-js\n```\n\n## Usage\n\nFirst, Start a Postgres instance with the PGMQ extension installed:\n\n```bash\ndocker run -d --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 quay.io/tembo/pgmq-pg:v1.2.1\n```\n\nThen:\n\n```ts\nimport { Pgmq } from 'pgmq-js';\n\nconsole.log('Connecting to Postgres...');\nconst pgmq = await Pgmq.new(\n  {\n    host: 'localhost',\n    database: 'postgres',\n    password: 'password',\n    port: 5432,\n    user: 'postgres',\n    ssl: false,\n  },\n  //  { skipExtensionCreation: true },  Set this if you want to bypass extension creation (e.g. dbdev users).\n).catch((err) =\u003e {\n  console.error('Failed to connect to Postgres', err);\n});\n\nconst qName = 'my_queue';\nconsole.log(`Creating queue ${qName}...`);\nawait pgmq.queue.create(qName).catch((err) =\u003e {\n  console.error('Failed to create queue', err);\n});\n\ninterface Msg {\n  id: number;\n  name: string;\n}\nconst msg: Msg = { id: 1, name: 'testMsg' };\nconsole.log('Sending message...');\nconst msgId = await pgmq.msg.send(qName, msg).catch((err) =\u003e {\n  console.error('Failed to send message', err);\n});\n\nconst vt = 30;\nconst receivedMsg = await pgmq.msg.read\u003cMsg\u003e(qName, vt).catch((err) =\u003e {\n  console.error('No messages in the queue', err);\n});\n\nconsole.log('Received message...');\nconsole.dir(receivedMsg.message, { depth: null });\n\nconsole.log('Archiving message...');\nawait pgmq.msg.archive(qName, msgId).catch((err) =\u003e {\n  console.error('Failed to archive message', err);\n});\n```\n\n## API\n\n## Supported Functionalities\n\n- [x] [Sending Messages](https://tembo-io.github.io/pgmq/api/sql/functions/#sending-messages)\n  - [x] [send](https://tembo-io.github.io/pgmq/api/sql/functions/#send)\n  - [x] [send_batch](https://tembo-io.github.io/pgmq/api/sql/functions/#send_batch)\n- [ ] [Reading Messages](https://tembo-io.github.io/pgmq/api/sql/functions/#reading-messages)\n  - [x] [read](https://tembo-io.github.io/pgmq/api/sql/functions/#read)\n  - [ ] [read_with_poll](https://tembo-io.github.io/pgmq/api/sql/functions/#read_with_poll)\n  - [x] [pop](https://tembo-io.github.io/pgmq/api/sql/functions/#pop)\n- [x] [Deleting/Archiving Messages](https://tembo-io.github.io/pgmq/api/sql/functions/#deletingarchiving-messages)\n  - [x] [delete (single)](https://tembo-io.github.io/pgmq/api/sql/functions/#delete-single)\n  - [x] [delete (batch)](https://tembo-io.github.io/pgmq/api/sql/functions/#delete-batch)\n  - [x] [purge_queue](https://tembo-io.github.io/pgmq/api/sql/functions/#purge_queue)\n  - [x] [archive (single)](https://tembo-io.github.io/pgmq/api/sql/functions/#archive-single)\n  - [x] [archive (batch)](https://tembo-io.github.io/pgmq/api/sql/functions/#archive-batch)\n- [ ] [Queue Management](https://tembo-io.github.io/pgmq/api/sql/functions/#queue-management)\n  - [x] [create](https://tembo-io.github.io/pgmq/api/sql/functions/#create)\n  - [ ] [create_partitioned](https://tembo-io.github.io/pgmq/api/sql/functions/#create_partitioned)\n  - [x] [create_unlogged](https://tembo-io.github.io/pgmq/api/sql/functions/#create_unlogged)\n  - [x] [detach_archive](https://tembo-io.github.io/pgmq/api/sql/functions/#detach_archive)\n  - [x] [drop_queue](https://tembo-io.github.io/pgmq/api/sql/functions/#drop_queue)\n- [x] [Utilities](https://tembo-io.github.io/pgmq/api/sql/functions/#utilities)\n  - [x] [set_vt](https://tembo-io.github.io/pgmq/api/sql/functions/#set_vt)\n  - [x] [list_queues](https://tembo-io.github.io/pgmq/api/sql/functions/#list_queues)\n  - [x] [metrics](https://tembo-io.github.io/pgmq/api/sql/functions/#metrics)\n  - [x] [metrics_all](https://tembo-io.github.io/pgmq/api/sql/functions/#metrics_all)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad-magdi%2Fpgmq-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhammad-magdi%2Fpgmq-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad-magdi%2Fpgmq-js/lists"}