Skip to content

Instantly share code, notes, and snippets.

@buren
Created November 2, 2022 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buren/68e909e0cb91d4279b7145a1e018ab0f to your computer and use it in GitHub Desktop.
Save buren/68e909e0cb91d4279b7145a1e018ab0f to your computer and use it in GitHub Desktop.
httpbin built with on a firebase function stored in firestore
import { firestore } from 'firebase-admin';
import * as functions from 'firebase-functions';
const region = 'europe-west1';
const firestoreCollection = 'webhook-posts';
export const httpBin = functions
.region(region)
.https.onRequest(async ({ headers, body }, response) => {
const data = { headers, body };
await firestore().collection(firestoreCollection).doc().create(data);
response.setHeader('Content-Type', 'application/json');
response.send(JSON.stringify(data));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment