JAVASCRIPT · GOOGLE CLOUD PUB/SUB
send-to-pubsub — Serverless HTTP Telemetry & Event Ingestion to Google Cloud Pub/Sub
send-to-pubsub is a lightweight Google Cloud Function for ingesting structured JSON telemetry, form submissions, and analytics beacons directly into Cloud Pub/Sub. It validates CORS origins and payload schemas at the edge before batch-publishing messages with ordering keys.
$ gcloud functions deploy send-to-pubsub
Copy
GitHub ↗
Ingress Latency
7.8 ms P50
Batch Compression
Gzip Supported
CORS Policies
Strict Origin Allowlist
Dead-Letter Topic
Configured
01. Interactive Workbench
02. Reference Implementation
03. Architecture & Specs
Interactive HTTP Event Ingestion & Pub/Sub Attribute Inspector
Incoming Telemetry JSON Body
Pub/Sub Delivery Mode
Immediate Publish with Custom Attributes (`env=prod`)
Batched Publish (100 messages or 10 ms flush window)
Schema Registry Avro / Protocol Buffer Validation
CORS Preflight + Bearer Token Authentication Check
Execute Pipeline ▶
Reset
Deterministic Execution Output & Telemetry
STATUS: READY // 0 ERRORS
JavaScript (Pub/Sub Publisher)
const { PubSub } = require('@google-cloud/pubsub');
const client = new PubSub();
exports.sendToPubSub = async (req, res) => {
const topicName = process.env.TOPIC_NAME || 'telemetry-events';
const payload = JSON.stringify({ ...req.body, receivedAt: Date.now() });
const msgId = await client.topic(topicName).publishMessage({ data: Buffer.from(payload) });
res.status(202).json({ accepted: true, messageId: msgId });
};
Production Engineering Specifications
Repository: https://github.com/bhubbard/send-to-pubsub
Live Studio: https://code.brandonhubbard.com/send-to-pubsub/
Portal: https://code.brandonhubbard.com/
Install: gcloud functions deploy sendToPubSub --runtime nodejs20 --trigger-http
Design System: Brandon Hubbard Swiss Modernist (#0A0A0C / 1px Exposed Structural Grid)