A wrapper for exposing a shared endpoint for Google Cloud Functions in go. API styled after Node.JS firebase-functions package.

firebase-fx

A wrapper for Google Cloud Functions that simplifies the deployment of serverless applications.

Meant to expose a similar API to the Firebase Functions package for node.js.

Features

  • Deployment
    • Output bash script
    • Profile memory for deployment: --memory flag
  • HTTP triggers
    • Unauthenticated
    • Methods, Headers, Host, Query
    • Middleware
  • Analytics
  • Firebase Authentication triggers
  • Firestore triggers
    • Document path wildcards
      • Access vars
    • Custom data types
    • fx tagged fields
      • string
      • number = float64/int
      • boolean = bool
      • map = struct OR map[string]interface{}
        • map = struct OR map[string]interface{}
      • array = []interface{}
      • geopoint = struct
      • timestamp = time.Time
  • PubSub triggers
    • Custom data types
  • Firebase Realtime Database triggers
    • Path wildcards
      • Access vars
    • Custom data types - JSON tags
  • Schedule triggers
  • Storage triggers

Usage

setup.go

package functions

import (
	"context"
	"fmt"

	register "github.com/schmorrison/firebase-fx"
)

var Register = register.Shared

func init() {
	Register.PubSub("my-topic").Publish(MyCustomData{}, func(ctx context.Context, msg register.PubSubMessage) error {
		fmt.Println(msg.Topic)
		if data, ok := msg.Data.(*MyCustomData); ok {
			// do something with v
			fmt.Println(data)
		}
		return nil
	})

	Register.Firestore().Collection("users").Document("{uid}").Create(MyUserData{}, func(ctx context.Context, e register.FirestoreEvent) error {
		fmt.Println(e.Vars()["uid"])

		if data, ok := e.Value.Fields.(*MyUserData); ok {
			// do something with v
			fmt.Println(data)
		}

		if data, ok := e.OldValue.Fields.(*MyUserData); ok {
			// do something with v
			fmt.Println(data)
		}
		return nil
	})
}

type MyCustomData struct {
	Name string
}

type MyUserData struct {
	Email string
}

deploy/deploy.go

package main

import (
	"fmt"

	functions "github.com/cleanflo/firebase-fx/functions"
	register "github.com/schmorrison/firebase-fx"
)

func main() {
	fmt.Println(functions.Register.
		WithEntrypoint("Register.EntryPoint").
		WithProjectID("my-project-id").
		WithRuntime("go116").
		Verbosity(register.DebugVerbosity).
		Deploy(),
	)
}

command

$ go run deploy/deploy.go

gcloud functions deploy  --entry-point "Register.EntryPoint" --runtime "go116" --project "my-project-id" --verbosity "debug" \
pubsubpublish-my-topic --trigger-topic "my-topic" &&  \
gcloud functions deploy  --entry-point "Register.EntryPoint" --runtime "go116" --project "my-project-id" --verbosity "debug" \
firestoreDocCreate-users-uid --trigger-event "providers/cloud.firestore/eventTypes/document.create" --trigger-resource "projects/my-project-id/databases/(default)/documents/users/{uid}"
Owner
Similar Resources

Serve endpoint metadata for client side load balancing

Servok Servok is a service that provides endpoint metadata for client side load balancing. See CONTRIBUTING.md for instructions on how to contribute a

Dec 9, 2021

Simple endpoint to create chat for specific application.

About Chat System Simple endpoint to create chat for specific application. Note This endpoints depend on chat-system repoistory, so you ought to run c

Nov 20, 2021

Gogrok is a self hosted, easy to use alternative to ngrok. It uses SSH as a base protocol, using channels and existing functionality to tunnel requests to an endpoint.

gogrok A simple, easy to use ngrok alternative (self hosted!) The server and client can also be easily embedded into your applications, see the 'serve

Dec 3, 2022

This is a tool that will proxy simple HTTPS requests to an external HTTP endpoint

 This is a tool that will proxy simple HTTPS requests to an external HTTP endpoint

AcmeShield A secured HTTP proxy that forwards requests from a remote service(Postman). This is a tool that will proxy simple HTTPS requests to an exte

Mar 21, 2022

Mauliasproxy - a simple room alias proxy that can respond to the federation alias query endpoint

Mauliasproxy - a simple room alias proxy that can respond to the federation alias query endpoint

Dec 22, 2022

node api for proxying requests with golang to spoof tls fingerprint

WIP NOT BUILT WONT WORK AS IS gotTLS A node websocket api version of https://github.com/Carcraftz/TLS-Fingerprint-API to spoof TLS fingerprint to prev

Sep 28, 2021

HTTP API for a DeSo node

About DeSo DeSo is a blockchain built from the ground up to support a fully-featured social network. Its architecture is similar to Bitcoin, only it s

Dec 24, 2022

This application demonstrates how to launch high-performance "serverless" functions from the YoMo framework to process streaming data. The functions are embedded in a WebAssembly VM, WasmEdge, for safety, security, portability, and manageability.

This application demonstrates how to launch high-performance

Streaming Image Recognition by WebAssembly This project demonstrates how to process a video stream in real-time using WebAssembly and apply a pre-trai

Nov 9, 2022

Provide cloud-edge message synergy solutions for companies and individuals.the cloud-edge message system based on NATS.

Swarm This project is a cloud-edge synergy solution based on NATS. quikly deploy cloud deploy on k8s #pull the project. git clone https://github.com/g

Jan 11, 2022
Related tags
An easy-to-use net tool for exposing local service to public.
An easy-to-use net tool for exposing local service to public.

gexpose An easy-to-use net tool for exposing local service to public. 一款简单易用的内网穿透工具 Architecture Usage Usage of ./gexpose: -server server mo

Nov 7, 2022
Turbine-common - This package contains the common interfaces for Turbine that are shared with other software

turbine-common This package contains the common interfaces for Turbine that are

Feb 12, 2022
A concurrent map with entries expiring after a specified interval.

go-ttlmap Go TTL Map is a concurent map with entries expiring after a specified interval. This package requires go1.14 or newer. Overview This impleme

Oct 13, 2021
Go-wd - Get the same working directory path at 'go run' and after 'go build'

go-wd Get the same working directory path at 'go run' and after 'go build' Usage

Jan 30, 2022
iflandown runs commands after the wired LAN link is down for a given amount of time.

iflandown iflandown runs commands after the wired LAN link is down for a given amount of time. All/most linux devices should work. Tested on amd64, Ra

Mar 16, 2022
Demonstration of using Pion WebRTC with a shared socket

pion-webrtc-shared-socket This example demonstrates how Pion WebRTC can use an already listening UDP socket. On startup we listen on UDP Socket 8000.

Apr 4, 2022
Code to be shared between EduVPN clients

EduVPN shared library This repository contains a Go library with functions that all EduVPN clients can use. The goal is to let EduVPN clients link aga

Mar 15, 2022
Socketlogger allows multiple processes to log to a shared log file between processes.
Socketlogger allows multiple processes to log to a shared log file between processes.

socketlogger socketlogger is a language agnostic logging utility designed to allow mulitple applications, running on one or multiple computers, to wri

Dec 7, 2021
Data Connector is a Google Sheets Add-on that lets you import (and export) data to/from Google Sheets

Data Connector Data Connector is a Google Sheets Add-on that lets you import (and export) data to/from Google Sheets. Our roadmap: Connect to JSON/XML

Jul 30, 2022
A simple server which can be used as an RPC endpoint in popular Ethereum wallets.

RPC Endpoint This repository contains code for a simple server which can be used as an RPC endpoint in popular Ethereum wallets. The endpoint is https

Jan 2, 2023