Brandon Hubbard Engineering / send-to-pubsub
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
GitHub ↗
Ingress Latency 7.8 ms P50
Batch Compression Gzip Supported
CORS Policies Strict Origin Allowlist
Dead-Letter Topic Configured
Interactive HTTP Event Ingestion & Pub/Sub Attribute Inspector
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)