{"id":19874523,"url":"https://github.com/strongloop/strong-pubsub-bridge","last_synced_at":"2025-05-02T10:31:20.271Z","repository":{"id":28894008,"uuid":"32418716","full_name":"strongloop/strong-pubsub-bridge","owner":"strongloop","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-19T10:12:34.000Z","size":22,"stargazers_count":6,"open_issues_count":4,"forks_count":10,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-07T01:05:39.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongloop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-17T20:33:51.000Z","updated_at":"2019-01-13T21:21:58.000Z","dependencies_parsed_at":"2022-09-03T07:41:38.111Z","dependency_job_id":null,"html_url":"https://github.com/strongloop/strong-pubsub-bridge","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-pubsub-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-pubsub-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-pubsub-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-pubsub-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongloop","download_url":"https://codeload.github.com/strongloop/strong-pubsub-bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252023261,"owners_count":21682153,"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":[],"created_at":"2024-11-12T16:23:51.008Z","updated_at":"2025-05-02T10:31:20.024Z","avatar_url":"https://github.com/strongloop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strong-pubsub-bridge\n\n**Create a bridge between a `Client` and a broker.**\n\n## Installation\n\n```\n$ npm install strong-pubsub-bridge\n```\n\n## Use\n\nUse `Bridge` for the following:\n\n - Bridge connections to brokers\n - Inject logic inbetween client actions (publish / subscribe / etc) and brokers\n - Adapt a connection that speaks one protocol to a broker that requires another \n\n**TCP**\n\nBelow is an example accepting a **tcp** connection, upgrading it to a\n**strong-pubsub** `Connection`, and creating a bridge to an **MQTT** broker.\n\n```js\n// tcp server\ntcpServer.on('connection', function(socket) {\n  var bridge = new Bridge(\n    // upgrade the tcp socket into a strong-pubsub-connection\n    new Connection(socket),\n    new Client({port: MOSQUITTO_PORT}, Adapter)\n  );\n\n  bridge.connect();\n});\n```\n\n**Primus**\n\nHere is an example that upgrades a **primus** `Spark` into a\n**strong-pubsub** `Connection` and creating a bridge to an **MQTT** broker.\n\n```js\n// primus server\nprimus.on('connection', function(spark) {\n  var bridge = new Bridge(\n    new Connection(spark),\n    new Client({port: MOSQUITTO_PORT}, Adapter)\n  );\n\n  bridge.connect();\n});\n```\n\n**Hooks**\n\nBelow is an example using a hook to inject a function to be invoked before an\naction is performed by the bridge on behalf of a `Connection`.\n\n```js\nbridge.before(action, function(ctx, next) {\n  console.log('about to publish to');\n  console.log(ctx.topic); // =\u003e \"my topic\"\n  next();\n});\n```\n\n## API\n\n[See the API docs.](http://apidocs.strongloop.com/strong-pubsub-bridge)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Fstrong-pubsub-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongloop%2Fstrong-pubsub-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Fstrong-pubsub-bridge/lists"}