{"id":17367880,"url":"https://github.com/baz-scm/pgmq-ts","last_synced_at":"2025-06-10T13:02:33.537Z","repository":{"id":257822279,"uuid":"870847284","full_name":"baz-scm/pgmq-ts","owner":"baz-scm","description":"Native SQL implementation for PGMQ in typescript, based on pgmq-rs","archived":false,"fork":false,"pushed_at":"2025-03-16T10:58:31.000Z","size":147,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-26T18:07:44.868Z","etag":null,"topics":["postgres","postgresql","queue"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baz-scm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2024-10-10T19:19:10.000Z","updated_at":"2025-04-21T06:50:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0e12137-00ae-41a0-9524-6091344e4cb5","html_url":"https://github.com/baz-scm/pgmq-ts","commit_stats":null,"previous_names":["baz-scm/pgmq-ts"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baz-scm%2Fpgmq-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baz-scm%2Fpgmq-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baz-scm%2Fpgmq-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baz-scm%2Fpgmq-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baz-scm","download_url":"https://codeload.github.com/baz-scm/pgmq-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baz-scm%2Fpgmq-ts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259080921,"owners_count":22802393,"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":["postgres","postgresql","queue"],"created_at":"2024-10-15T23:05:14.203Z","updated_at":"2025-06-10T13:02:33.443Z","avatar_url":"https://github.com/baz-scm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PGMQ-TS\n\n[![npm version](https://badge.fury.io/js/@baz-scm%2Fpgmq-ts.svg)](https://www.npmjs.com/package/@baz-scm/pgmq-ts)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nPGMQ-TS is a TypeScript library that provides a message queue implementation using PostgreSQL as the backend. It's the TypeScript equivalent of pgmq-rs, offering a robust and type-safe way to implement message queues in your Node.js applications.\n\n## Features\n\n- 🔒 **Type-safe**: Full TypeScript support with generics for message types\n- 🎯 **Simple API**: Easy-to-use interface for queue operations\n- 📦 **PostgreSQL-backed**: Leverages PostgreSQL's reliability and ACID properties\n- 🔄 **Message Visibility**: Configurable visibility timeout for message processing\n- 📚 **Message Archives**: Built-in support for archiving processed messages\n- 🔌 **Connection Pooling**: Efficient database connection management\n\n## Installation\n\n```bash\nnpm install @baz-scm/pgmq-ts\n# or\nyarn add @baz-scm/pgmq-ts\n# or\npnpm add @baz-scm/pgmq-ts\n```\n\n## Quick Start\n\n```typescript\nimport { PGMQ } from '@baz-scm/pgmq-ts';\n\n// Initialize PGMQ with your PostgreSQL connection string\nconst pgmq = new PGMQ('postgresql://user:password@localhost:5432/dbname');\n\n// Create the PGMQ schema and a queue\nawait pgmq.createSchema();\nawait pgmq.createQueue('my_queue');\n\n// Define your message type\ninterface MyMessage {\n  id: string;\n  data: {\n    value: string;\n  };\n}\n\n// Send a message\nawait pgmq.sendMessage\u003cMyMessage\u003e('my_queue', {\n  id: '123',\n  data: {\n    value: 'Hello PGMQ!'\n  }\n}, 0);\n\n// Read a message (with 60 second visibility timeout)\nconst message = await pgmq.readMessage\u003cMyMessage\u003e('my_queue', 60);\n\nif (message) {\n  // Process the message\n  console.log(message.message); // Access the typed message content\n  \n  // After processing, either delete or archive the message\n  await pgmq.deleteMessage('my_queue', message.msgId);\n  // or\n  await pgmq.archiveMessage('my_queue', message.msgId);\n}\n```\n\n## Queue Operations\n\n### Creating a Queue\n\n```typescript\nawait pgmq.createQueue('my_queue');\n```\n\n### Using Queue Objects\n\nYou can also get a Queue object for more focused operations:\n\n```typescript\nconst queue = pgmq.getQueue('my_queue');\n\n// Read messages from the queue\nconst message = await queue.readMessage\u003cMyMessage\u003e();\n\n// Delete a message\nawait queue.deleteMessage(messageId);\n\n// Archive a message\nawait queue.archiveMessage(messageId);\n```\n\n### Message Visibility\n\nThe visibility timeout determines how long a message stays hidden after being read. This prevents other consumers from processing the same message during this period:\n\n```typescript\n// Message will be hidden for 60 seconds after being read\nconst message = await pgmq.readMessage\u003cMyMessage\u003e('my_queue', 60);\n```\n\n## Best Practices\n\n1. Always define TypeScript interfaces for your message types\n2. Handle connection cleanup by calling `pgmq.end()` when shutting down\n3. Use appropriate visibility timeouts based on your processing needs\n4. Consider archiving important messages instead of deleting them\n5. Validate queue names (alphanumeric and underscore characters only)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaz-scm%2Fpgmq-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaz-scm%2Fpgmq-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaz-scm%2Fpgmq-ts/lists"}