{"id":27245421,"url":"https://github.com/jasonmejane/ts-post","last_synced_at":"2025-10-07T21:43:25.263Z","repository":{"id":46041214,"uuid":"514922112","full_name":"JasonMejane/ts-post","owner":"JasonMejane","description":"Flexible PubSub messaging bus system for node and browser applications","archived":false,"fork":false,"pushed_at":"2024-09-02T13:44:39.000Z","size":722,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T17:55:18.385Z","etag":null,"topics":["bus","event","messaging","publish-subscribe","pubsub","typescript"],"latest_commit_sha":null,"homepage":"","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/JasonMejane.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":"2022-07-17T18:18:38.000Z","updated_at":"2024-06-06T01:21:26.000Z","dependencies_parsed_at":"2023-02-13T22:30:27.561Z","dependency_job_id":"19a37825-a753-4fef-98dc-5ee4d8ff2e10","html_url":"https://github.com/JasonMejane/ts-post","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.16129032258064513","last_synced_commit":"c913450c6adadd923354830c30fa30679d6008ac"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/JasonMejane/ts-post","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonMejane%2Fts-post","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonMejane%2Fts-post/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonMejane%2Fts-post/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonMejane%2Fts-post/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JasonMejane","download_url":"https://codeload.github.com/JasonMejane/ts-post/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonMejane%2Fts-post/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278854218,"owners_count":26057418,"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-10-07T02:00:06.786Z","response_time":59,"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":["bus","event","messaging","publish-subscribe","pubsub","typescript"],"created_at":"2025-04-10T21:19:07.460Z","updated_at":"2025-10-07T21:43:25.246Z","avatar_url":"https://github.com/JasonMejane.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-post\n\n\u003cdiv style=\"text-align: center;\"\u003e\n\n![](ts-post.png \"ts-post logo\")\n\n\u003c/div\u003e\n\n\u003cp style=\"text-align: center;\"\u003e\n\t\u003cb\u003eFlexible PubSub messaging bus system for node and browser applications.\u003c/b\u003e\n\t\u003cbr/\u003e\n\t\u003cbr/\u003e\n\t\u003ca href=\"https://github.com/JasonMejane/ts-post\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/github/v/release/JasonMejane/ts-post\" alt=\"Release\" /\u003e\n\t\u003c/a\u003e\u0026nbsp;\n\t\u003ca href=\"https://www.npmjs.com/ts-post\"\u003e\n    \t\u003cimg src=\"https://img.shields.io/npm/v/ts-post.svg?logo=npm\u0026logoColor=fff\u0026label=NPM+package\u0026color=limegreen\" alt=\"ts-post on npm\" /\u003e\n\t\u003c/a\u003e\u0026nbsp;\n\t\u003cspan\u003e\n\t\t\u003cimg src=\"https://img.shields.io/bundlephobia/min/ts-post\" alt=\"Package size\" /\u003e\n\t\u003c/span\u003e\u0026nbsp;\n\t\u003ca href=\"https://github.com/JasonMejane/ts-post/blob/master/LICENSE\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/github/license/JasonMejane/ts-post\" alt=\"Licence\" /\u003e\n\t\u003c/a\u003e\n\t\u003cspan\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/dependencies-0-success\" alt=\"Dependencies\" /\u003e\n\t\u003c/span\u003e\u0026nbsp;\n\t\u003ca href=\"https://github.com/JasonMejane/ts-post/issues\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/github/issues/JasonMejane/ts-post\" alt=\"Issues\" /\u003e\n\t\u003c/a\u003e\u0026nbsp;\n\t\u003cbr/\u003e\n\t\u003cspan\u003e\n\t\t\u003cimg src=\"https://github.com/JasonMejane/ts-post/actions/workflows/nodejs_ci_main.yml/badge.svg\" alt=\"Node.js CI\" /\u003e\n\t\u003c/span\u003e\u0026nbsp;\n\t\u003cspan\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/coverage-100%25-success\" alt=\"Coverage\" /\u003e\n\t\u003c/span\u003e\u0026nbsp;\n\u003c/p\u003e\n\n## Install\n\nIn terminal, run:\n```sh\nnpm i ts-post\n```\n\n## Basic usage\n\n\u003cb\u003ets-post\u003c/b\u003e allows you to create multiple buses to better segment and handle what messages the subscribers will receive or not.\nThis encourages you to have a well defined type for message data going through each bus, helping limiting potential errors where callbacks would have tried to handle different objects than expected.\nThe singleton instance of Port has to be created globally, in order to be accessible everywhere in your app without risk of undelivered messages.\nBy default, a bus named `default` is created.\n\n### Import\n\n```typescript\nimport { Message, Post, Subscription } from 'ts-post';\n```\n\n### Example\n\n```typescript\nconst post = Post.getInstance;\n\n// Create a new bus called foo, which will dispatch messages only to foo subcribers\npost.createBus('foo');\n\n// Subscribe to the bus\nconst sub = post.subscribe('foo', {\n    callback: async (message: Message) =\u003e {\n        console.log(`Message timestamp: ${message.getTimestamp()} - issuer: ${message.getIssuer()}`);\n        await doSomethingWithData(message.getData());\n    },\n    errorHandler: (error) =\u003e { console.error(error); }\n});\n\n// Publish a message into the bus\nawait post.publish('foo', new Message({ id: 'bar', description: 'some data', available: 104 }, 'FooService'));\n\n// Unsubscribe\nsub.unsubscribe();\n```\n\n\n## Options and data\n\n### Subscriber\nThe available options are:\n- `callback` (required): the callback to execute when receiving a message\n- `errorHandler` (optional): the callback to execute in case of exception while executing the callback\n- `delay` (optional): the delay before executing the callback\n  - If undefined, the callback will be executed immediatly and synchronously (according to its order in the subscribers list)\n  - If \u003e= 0, the callback will be put in the event loop using `setTimeout`\n\nWhen subscribing, the returned subscriber can call `.unsubscribe()` to remove the subscription to the bus.\n\n### Message\nWhen creating a message to be published, the options are:\n- `data` (required): the actual data to send\n- `issuer` (optional): the app component/service/... responsible for the message publishing\n\nThe data sent is packaged with additional info:\n- `getData` returns the data sent in the message\n- `getTimestamp` returns the creation time (in ms) of the message\n- `getIssuer` returns the issuer of the message (if defined)\n\n## Contribute\n\nPlease feel free to suggest features or bug fix through Git issues. Pull Requests for that are also more than welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonmejane%2Fts-post","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonmejane%2Fts-post","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonmejane%2Fts-post/lists"}