All Projects → chidindu-ogbonna → cloud-functions-boilerplate

chidindu-ogbonna / cloud-functions-boilerplate

Licence: other
An ever-evolving, opinionated architecture, starter kit, and development environment for writing and structuring google cloud functions for firebase.

Programming Languages

typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to cloud-functions-boilerplate

Pure
Pure is a free social networking App. it is simple, reliable and it makes it easy to keep in touch with your friends and family. Pure works across mobile devices even on slow internet connections.
Stars: ✭ 28 (-30%)
Mutual labels:  cloud-functions
barber-shop
Vue + Firebase (cloud functions, auth, firestore, hosting) reservations system
Stars: ✭ 47 (+17.5%)
Mutual labels:  cloud-functions
node-starter-kit
Node.js / GraphQL project template pre-configured with TypeScript, PostgreSQL, login flow, transactional emails, unit tests, CI/CD workflow.
Stars: ✭ 76 (+90%)
Mutual labels:  cloud-functions
fireschema
Strongly typed Firestore framework for TypeScript
Stars: ✭ 193 (+382.5%)
Mutual labels:  cloud-functions
argon
Campaign Manager 360 and Display & Video 360 Reports to BigQuery connector
Stars: ✭ 31 (-22.5%)
Mutual labels:  cloud-functions
tyfon
typed functions over network
Stars: ✭ 38 (-5%)
Mutual labels:  cloud-functions
okr-tracker
A front-end application for tracking Objectives and Key Results (OKRs) and Key performance indicators (KPIs) for product teams with a Google Firebase backend.
Stars: ✭ 32 (-20%)
Mutual labels:  cloud-functions
Angularfire
The official Angular library for Firebase.
Stars: ✭ 7,029 (+17472.5%)
Mutual labels:  cloud-functions
serverless-ktp-ocr
Serverless Indonesian Identity E-KTP OCR with Google Cloud Platform (GCP) - Cloud Functions, Cloud Storage, and Cloud PubSub
Stars: ✭ 54 (+35%)
Mutual labels:  cloud-functions
end-to-end-machine-learning-with-google-cloud
End to End Machine Learning with Google Cloud Platform
Stars: ✭ 39 (-2.5%)
Mutual labels:  cloud-functions
functions-framework-php
FaaS (Function as a service) framework for writing portable PHP functions
Stars: ✭ 186 (+365%)
Mutual labels:  cloud-functions
dataflow-contact-center-speech-analysis
Speech Analysis Framework, a collection of components and code from Google Cloud that you can use to transcribe audio files to create analytics.
Stars: ✭ 46 (+15%)
Mutual labels:  cloud-functions
spica
Spica is a development engine to build fast & efficient applications.
Stars: ✭ 77 (+92.5%)
Mutual labels:  cloud-functions
firebase-jest-testing
Firebase back-end testing, using Jest.
Stars: ✭ 21 (-47.5%)
Mutual labels:  cloud-functions
rowy
Open-source Airtable-like experience for your database (Firestore) with GCP's scalability. Build any automation or cloud functions for your product. ⚡️✨
Stars: ✭ 2,676 (+6590%)
Mutual labels:  cloud-functions
foundry-cli
Foundry makes the development of Firebase Functions fast by giving you an out-of-the-box working cloud environment for your development with an access to your production data. It's a CLI tool that gives you a continuous REPL-like feedback about your Firebase Functions.
Stars: ✭ 49 (+22.5%)
Mutual labels:  cloud-functions
universal-translator
Demo app using Firebase and Google Cloud products to implement a "universal translator"
Stars: ✭ 37 (-7.5%)
Mutual labels:  cloud-functions
container-builder-github-ci-status
Google Cloud Function responds to PubSub events on the cloud-builds topic to update GitHub CI status.
Stars: ✭ 23 (-42.5%)
Mutual labels:  cloud-functions
Miniprogram Demo
微信小程序组件 / API / 云开发示例
Stars: ✭ 5,207 (+12917.5%)
Mutual labels:  cloud-functions
fb-watson
Hands-on developing an application using IBM Watson services with Facebook Messenger integrated through serverless functions
Stars: ✭ 19 (-52.5%)
Mutual labels:  cloud-functions

Cloud Functions For Firebase Boilerplate

Cloud Functions For Firebase Boilerplate

An ever-evolving, opinionated architecture and development environment for writing and structuring google cloud functions for firebase. It takes into account performance of cloud functions, and developer productivity.

As this project is a template project and not a CLI, you have access to the entire app configuration so you can change it according to your needs.

Questions, feedback, and contributions are welcome!

Why is this important?

The simplicity of Cloud Functions lets you quickly develop code and run it in a serverless environment. At moderate scale, the cost of running functions is low, and optimizing your code might not seem like a high priority. As your deployment scales up, however, optimizing your code becomes increasingly important.

-- Cloud Functions For Firebase Documentation

Features

  • Improved cold start performance - Cold start/boot time is one of the biggest issues many developers and companies come across when using cloud functions. This boilerplate uses the best practices to reduce the cold start time thus improving performance.

  • Improved readability & developer experience - Using only one file, index.js for everything doesn't work for a serious app. It becomes hard to scan through, hard to easily follow up with the code. This boilerplate recognizes that and aims to solve that.

  • TypeScript - While everything done here can be achieved using plain JavaScript, it would require more code, a lot of experience using JavaScript, and time, which in my opinion is counter-intuitive. You should not have to spend time optimizing the tool to achieve a task!

  • Express.js - Every HTTP request makes use of express.js underneath, but explicitly using it in structuring your endpoints has proved to more beneficial, both in structure and maximization of resources.

  • Eslint setup - An extensible eslint configuration, that gets you up and running

Getting Started

Installation

# 1. Clone the repository
git clone https://github.com/chidindu-ogbonna/cloud-functions-boilerplate

# 2. Enter the newly cloned folder
cd cloud-functions-boilerplate

# 3. Init cloud functinos for firebase. Make sure firebase-tools is installed: npm install -g firebase-tools
firebase init

# Go through the prompt selecting this options

# Select functions from the options
# Select the required project
# What language would you like to use to write Cloud Functions? TypeScript
# Do you want to use TSLint to catch probable bugs and enforce style? n
# File functions/package.json already exists. Overwrite? N
# File functions/tsconfig.json already exists. Overwrite? N
# File functions/src/index.ts already exists. Overwrite? N
# File functions/.gitignore already exists. Overwrite? N
# Do you want to install dependencies with npm now? y

Service Accounts and Permissions

You can view all service accounts associated with your project in the Service account tab of your Project Settings in the Firebase console.

Place your service account files in the service-account folder, based on environments

You can name your service accounts whatever you like, but make sure to change the sections where the service account file is referenced.

  • Production environment: Rename your service account file to prod-service-account.json

  • Staging environment: Rename your service account to file staging-service-account.json

  • Development environment: Rename your service account to file dev-service-account.json

Testing

After setting up the environment, service accounts and permissions, testing becomes the next thing.

Run npm run local in your terminal to run functions locally.

Example Folder Structure

Folder Structure

Documentation

Improved cold start performance

Cold start (Cold boot) time has been one of the biggest issues many developers and companies come across when using cloud functions. This boilerplate uses the best practices to reduce the cold start time thus improving performance.

By taking advantage of TypeScripts dynamic 'async' import, this ensures unused code and imports and not loaded unncessarily during start time but only when the specific function is invoked.

Improved readability & developer experience

Using only one file, index.js, for everything doesn't work for a serious app. It becomes hard to scan through, hard to easily follow up with the code. This boilerplate recognizes that and aims to solve that.

There have been a lot of ways suggested to split cloud functions properly, Firebase also has suggestions, but it doesn't take into account the effect on the cold start time.

TypeScript

While everything done here can be achieved using plain JavaScript, it would require more code, more time, and a lot of experience using JavaScript, which in my opinion is counter-intuitive. You should not have to spend time fighting with the tool and trying to optimize it to achieve a task.

TypeScript removes that overhead, providing a more convenient means of writing JavaScript. It's also advised to write cloud functions using TypeScript.

Express.js

Every Firebase HTTP function makes use of express.js underneath. Explicitly using it in structuring your endpoints has proved to more beneficial, both in structure and maximization of resources.

  • All your HTTP requests are now accessed through one Cloud Function. This helps with the "Number of functions" limit (which is 1,000), meaning no matter the number of endpoints you have, they would all count as one function.
  • Improves cold start time - Due to the way cloud functions are invoked, having all endpoints accessible through one function enables instances to be reused.

Eslint setup

An extensible eslint configuration, that gets you up and running

Resources

TODO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].