{"id":21970712,"url":"https://github.com/appcelerator/appc-pubsub","last_synced_at":"2025-04-28T11:25:20.364Z","repository":{"id":34722504,"uuid":"38700003","full_name":"appcelerator/appc-pubsub","owner":"appcelerator","description":"Appcelerator PubSub client library","archived":false,"fork":false,"pushed_at":"2025-03-12T19:49:12.000Z","size":577,"stargazers_count":2,"open_issues_count":0,"forks_count":11,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-28T11:25:11.126Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appcelerator.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":"2015-07-07T16:19:22.000Z","updated_at":"2025-03-12T19:49:18.000Z","dependencies_parsed_at":"2024-01-05T01:31:28.413Z","dependency_job_id":"6eb7084f-3a71-4f0f-bcc9-d9bb9477f448","html_url":"https://github.com/appcelerator/appc-pubsub","commit_stats":{"total_commits":134,"total_committers":9,"mean_commits":14.88888888888889,"dds":0.6119402985074627,"last_synced_commit":"9e52ed62efb9f252b7fcf52d6cd515cbafe15027"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcelerator%2Fappc-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcelerator%2Fappc-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcelerator%2Fappc-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appcelerator%2Fappc-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appcelerator","download_url":"https://codeload.github.com/appcelerator/appc-pubsub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251303632,"owners_count":21567727,"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-29T14:41:59.645Z","updated_at":"2025-04-28T11:25:20.344Z","avatar_url":"https://github.com/appcelerator.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Appcelerator PubSub Client library\n\n [![NPM version](https://badge.fury.io/js/appc-pubsub.svg)](http://badge.fury.io/js/appc-pubsub)\n\nThe library makes it easy to publish events to the Appcelerator PubSub API service.\n\n## Installation\n\n    npm install appc-pubsub --save\n\n## Usage\n\nYou must first include the library and create an instance.  At a minimum, you must pass in the `key` and `secret` values for constructing the client.\n\n```javascript\nconst PubSubClient = require('appc-pubsub');\nconst pubsub = new PubSubClient({\n  key: 'MY_KEY',\n  secret: 'MY_SECRET'\n});\n```\n\nOnce you have created the client instance, you can publish events.\n\n```javascript\npubsub.publish('com.foo.bar');\n```\n\nYou can optional pass payload data for your event by passing an object as the second parameter:\n\n```javascript\npubsub.publish('com.foo.bar', { bar: 1 });\n```\n## Events\n\n### Configured\nEmitted when the configurations (APIKey, secret..etc) are authenticated successfully by PubSub server.\n\n```javascript\npubsub.on('configured', function (config) {\n  //do something ...\n});\n\n//example of the returned config object: \n{\n  can_publish: true,\n  can_consume: false,\n  events: {},\n  auth_type: 'key_secret'\n}\n```\n\n### Response\nEmitted when an event is successfully sent.The `response` object that returned by the call-back contains a raw data of the event request (HTTP). i.e. `statusCode`,`body` etc... keys are available.\n\n```javascript\npubsub.on('response', function (response) {\n  //do something ...\n});\n```\n\n### Event (WebHook)\n*Note: Make sure the client has consumption enabled, check `can_consume` in the returned config object.*\n\nEmitted when an event is received and that matches the subscribed topic.\nEvent's payload (object) will be returned by the call-back function\n\n```javascript\nconst topicName = 'com.foo.downloaded'\npubsub.on(`event:${topicName}`, function (event) {\n  // Log event name and data\n  console.log(event.event);\n  console.log(event.data);\n  //do something with the event...\n});\n```\n\n### Retry\nEmitted when an event is rescheduled to re-sending. The event will be emitted first then the re-send occurs.\n\n *500ms Max time between event's emitting and re-sending*\n\n```javascript\npubsub.on('retry', function (data) {\n  //do something ...\n});\n```\n\n### Unauthorized\nEmitted when the client couldn't connect to the PubSub server due to bad credentials. i.e. HTTP code *401*\n\n```javascript\npubsub.on('unauthorized', function (error) {\n  //do something ...\n});\n```\n\n### Logging\n\nLogging is handled using the debug module with appc-pubsub:info and appc-pubsub:error namespaces. Logging can be enabled as part of the configuration options.\n\n```javascript\nconst pubsub = new PubSubClient({\n  key: 'MY_KEY',\n  secret: 'MY_SECRET',\n  debug: 'info', 'error' or true\n});\n```\n\n## License\n\nThe library is Confidential and Proprietary to Appcelerator, Inc. and licensed under the Appcelerator Software License Agreement. Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappcelerator%2Fappc-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappcelerator%2Fappc-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappcelerator%2Fappc-pubsub/lists"}