Coder Social home page Coder Social logo

olegkorol / firebase-cloud-functions-typescript Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 4.0 945 KB

Boilerplate code with multiple Firebase Cloud Functions in one repository

TypeScript 100.00%
firebase cloud-function-for-firebase typescript firebase-admin-sdk

firebase-cloud-functions-typescript's Introduction

firebase-cloud-functions-typescript

Firebase Cloud Functions (TypeScript)

Quick start

Requirement: Node.js >= v.8

# To quickly deploy (or update existing) Firebase Functions to GCP:
$ cd firebase-functions
$ npm install
# set your default project name in the firebase.json file, and then run:
$ npm run deploy

# In order to deploy single functions, you will have to install `firebase-tools` locally:
$ npm install -g firebase-tools
$ firebase deploy --only functions:{functionName}
# The function names can be found in firebase-functions/src/index.ts, e.g. "firebase_firebaseFunction1"

The "deploy" command will run tslint, transpile into JavaScript (ES2017) under the "lib" directory, perform unit tests and deploy the transpiled code to Google Cloud Platform.

Important note: All functions using the "firebase-admin" SDK should initialize the SDK in the following manner:

import * as functions from 'firebase-functions';
import * as admin from "firebase-admin";
try {admin.initializeApp(functions.config().firebase);} catch(e) {}

Otherwise, the SDK might be initialized more than once - which will lead to an error on deployment.

Unit Testing

The Firebase Cloud Functions use unit tests using Mocha and Chai for assertions.

Creating new functions

Create a .ts file under firebase-functions/src/.

After that export the function in the index.ts file.

If you want to create any unit tests, do so in the test folder.

firebase-cloud-functions-typescript's People

Contributors

dependabot[bot] avatar olegkorol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.