Skip to content

cerebral/firebase-functions-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

firebase-functions-mock

Work locally with firebase functions

Install

npm install firebase-functions-mock

Supports

  • onRequest express app handling
  • onWrite database event handling
  • Mocks out auth and config
  • Runs static delivery of your public files folder

How to use

functions/index.js

const firebase = require('firebase-admin');
const admin = firebase.initializeApp({
  credential: firebase.credential.cert(JSON.parse(process.env.SERVICE_ACCOUNT)),
  databaseURL: JSON.parse(process.env.FIREBASE_CONFIG).databaseURL,
});
let functions = require('firebase-functions');

// When in debug mode, override functions with the mock and
// pass in the instance of "admin" and optional options
if (process.env.NODE_ENV !== 'production') {
  functions = require('firebase-functions-mock')(admin, {
    config: process.env.FIREBASE_CONFIG,
    port: 3001,
    publicPath: 'public'
  });
}

exports.app = functions.https.onRequest(require('./app'));
exports.publish = functions.database.ref('articles/{uid}/{articleName}').onWrite(require('./publish'));

Limitations

This project is in its initial state to build the jsblog.io project. It has a lot of potential for improvements. Although contributions are already made, here are some things to look into:

  • Test more scenarios with onWrite usage

Get going

To get going with Firebase Functions I highly recommend using this boilerplate which has the whole workflow set up for you.

About

Work locally with firebase functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •