firebase-functions-local

4.1.0 • Public • Published

firebase-functions-local

CircleCI

Work locally with firebase functions. Great for developing your functions without having to wait for them to deploy. Allows you to attach a debugger and avoid scrolling through endless console.log()s. Uses live data from your firebase realtime db as the trigger.

Requires firebase-functions version 1+.

Install

npm install firebase-functions-local

Supports

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

How to use

functions/index.js

const admin = require('firebase-admin');
 
// Initialize the admin sdk
// This must be done before using firebase-functions-local
// See https://firebase.google.com/docs/admin/setup#initialize_the_sdk
const serviceAccount = require('path/to/serviceAccountKey.json');
 
const admin = admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: 'https://your-project-id.firebaseio.com', // Replace these with your own values
  storageBucket: 'your-project-id.appspot.com',
});
 
const functions = require('firebase-functions-local')({
  config: {}, // Set functions.config() values
  port: 3001,
  publicPath: 'public'
});
 
exports.app = functions.https.onRequest(require('./app'));
exports.publish = functions.database.ref('articles/{uid}/{article}').onWrite(require('./publish'));

Limitations

  • Functions that have been deployed using firebase deploy will run concurrently with firebase-functions-local. These should be disabled before using this library or you may get strange results.
  • In order to generate Change objects the existing database state has to be loaded on startup. This can cause delays before the local functions become response.
  • Unable to listen to paths that have large response items or too many children. https://firebase.google.com/docs/database/usage/limits

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i firebase-functions-local

Weekly Downloads

1

Version

4.1.0

License

MIT

Unpacked Size

12.9 kB

Total Files

7

Last publish

Collaborators

  • crazometer