{"id":18615027,"url":"https://github.com/andrewjbateman/cloud-pubsub-firebase","last_synced_at":"2026-04-30T14:32:06.064Z","repository":{"id":96859132,"uuid":"394423617","full_name":"AndrewJBateman/cloud-pubsub-firebase","owner":"AndrewJBateman","description":":clipboard: Google Firebase Functions used to transfer data using Pubsub to a Firestore Database","archived":false,"fork":false,"pushed_at":"2021-08-10T15:15:02.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-17T01:34:29.638Z","etag":null,"topics":["firebase","functions","google-cloud","pubsub","tutorial-code","typescript3"],"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/AndrewJBateman.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2021-08-09T20:04:21.000Z","updated_at":"2021-08-10T20:23:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2f4b18d-e99e-42f5-83b5-e3b92a8745e9","html_url":"https://github.com/AndrewJBateman/cloud-pubsub-firebase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AndrewJBateman/cloud-pubsub-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fcloud-pubsub-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fcloud-pubsub-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fcloud-pubsub-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fcloud-pubsub-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndrewJBateman","download_url":"https://codeload.github.com/AndrewJBateman/cloud-pubsub-firebase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewJBateman%2Fcloud-pubsub-firebase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32468009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["firebase","functions","google-cloud","pubsub","tutorial-code","typescript3"],"created_at":"2024-11-07T03:27:51.731Z","updated_at":"2026-04-30T14:32:06.028Z","avatar_url":"https://github.com/AndrewJBateman.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloud Pubsub Firebase\n\n* Publish data to Pub/Sub and write a cloud function to write to Cloud Firestore database\n* Tutorial code from [D-I-Ry](https://www.youtube.com/channel/UCMHvK9tare9Y9O152C9wm3Q) with some modifications - see [:clap: Inspiration](#clap-inspiration) below\n* **Note:** to open web links in a new window use: _ctrl+click on link_\n\n![GitHub repo size](https://img.shields.io/github/repo-size/AndrewJBateman/cloud-pubsub-firebase?style=plastic)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/AndrewJBateman/cloud-pubsub-firebase?style=plastic)\n![GitHub Repo stars](https://img.shields.io/github/stars/AndrewJBateman/cloud-pubsub-firebase?style=plastic)\n![GitHub last commit](https://img.shields.io/github/last-commit/AndrewJBateman/cloud-pubsub-firebase?style=plastic)\n\n## :page_facing_up: Table of contents\n\n* [Cloud Pubsub Firebase](#cloud-pubsub-firebase)\n  * [:page_facing_up: Table of contents](#page_facing_up-table-of-contents)\n  * [:books: General info](#books-general-info)\n  * [:camera: Screenshots](#camera-screenshots)\n  * [:signal_strength: Technologies](#signal_strength-technologies)\n  * [:floppy_disk: Setup](#floppy_disk-setup)\n  * [:computer: Code Examples](#computer-code-examples)\n  * [:cool: Features](#cool-features)\n  * [:clipboard: Status \u0026 To-Do List](#clipboard-status--to-do-list)\n  * [:clap: Inspiration](#clap-inspiration)\n  * [:file_folder: License](#file_folder-license)\n  * [:envelope: Contact](#envelope-contact)\n\n## :books: General info\n\n* Google Cloud Pub/Sub is a messaging service for exchanging event data among applications and services.\n* Code is written in Typescript\n\n## :camera: Screenshots\n\n![Frontend screenshot](./img/pubsub.png)\n\n## :signal_strength: Technologies\n\n* [Firebase Cloud Functions](https://firebase.google.com/docs/functions) serverless framework to automatically run backend code\n* [Firebase Pubsub](https://firebase.google.com/docs/functions/pubsub-events) globally distributed message bus using [message topic 'factory-sensors'](https://cloud.google.com/sdk/gcloud/reference/alpha/pubsub/topics/publish)\n\n## :floppy_disk: Setup\n\n* Ref. tutorial: create new project in Google Cloud Firebase console.\n* Select project from VS code terminal e.g. `gcloud config set project cloud-pubsub-firebase-322407`\n* Deploy project: `firebase deploy --functions` - 2x `lib` JS files created. Check deployment in console Functions dashboard\n* Submit data e.g. `gcloud pubsub topics publish factory-sensors --message '{\"sensorLocation\":\"London Underground\", \"sensorReference\": \"0014567\"}' --attribute sensorName=sensor-003,temperature=99,humidity=95,pressure=40` Note JSON format of sensorLocation\n* View message in Google Cloud Platform Pub/Sub - 'View Messages' and click on 'PULL'\n* data stored in FireStore datebase in a collection that is created if it does not exist\n\n## :computer: Code Examples - by [D-I-Ry](https://www.youtube.com/channel/UCMHvK9tare9Y9O152C9wm3Q) with some modifications\n\n* function to transfer data using pub/sub\n\n```typescript\nexports.insertFromPubsub = functions.pubsub\n\t.topic('factory-sensors')\n\t.onPublish((message, context) =\u003e {\n\t\tconsole.log('The function was triggered at ', context.timestamp);\n\n\t\tlet sensorLocation = '';\n    let sensorReference = '';\n\t\ttry {\n\t\t\tsensorLocation = message.json.sensorLocation;\n      sensorReference = message.json.sensorReference;\n\t\t} catch (e) {\n\t\t\tfunctions.logger.error('PubSub message not in JSON format. error:', e);\n\t\t}\n\n\t\tlet sensorName = '';\n\t\tlet temperature = '';\n\t\tlet humidity = '';\n    let pressure = '';\n\n\t\ttry {\n\t\t\tsensorName = message.attributes.sensorName;\n\t\t\ttemperature = message.attributes.temperature;\n\t\t\thumidity = message.attributes.humidity;\n      pressure = message.attributes.pressure;\n      console.log('sensorName', sensorName);\n      console.log('temperature', temperature);\n      console.log('humidity', humidity);\n      console.log('pressure', pressure);\n\n\t\t} catch (e) {\n\t\t\tfunctions.logger.error('PubSub message attributes error:', e);\n\t\t}\n\n\t\tconst sensorInfo = {\n\t\t\tsensorLocation: sensorLocation,\n      sensorReference: sensorReference,\n\t\t\tsensorName: sensorName,\n\t\t\ttemperature: temperature,\n\t\t\thumidity: humidity,\n      pressure: pressure\n\t\t};\n\n\t\treturn admin.firestore().collection('factorySensors').add(sensorInfo);\n\t});\n```\n\n## :cool: Features\n\n* Firebase setup is always quick to do\n\n## :clipboard: Status \u0026 To-Do List\n\n* Status: Working\n* To-Do: Nothing\n\n## :clap: Inspiration\n\n* [D-I-Ry: Cloud Functions: moving data from Pubsub to Firebase Cloud Firestore in TypeScript](https://www.youtube.com/watch?v=3Zohd6U6CL8)\n\n## :file_folder: License\n\n* N/A\n\n## :envelope: Contact\n\n* Repo created by [ABateman](https://github.com/AndrewJBateman), email: gomezbateman@yahoo.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fcloud-pubsub-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewjbateman%2Fcloud-pubsub-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewjbateman%2Fcloud-pubsub-firebase/lists"}