Fireface
A convenient interface for Firebase developers.
Purpose
Firebase is an excellent tool to have in the developer's kit, and while its standard interface is robust, it can be helpful to have some simple abstractions for common patterns, such as fetching data one time, setting and updating records, and performing queries against your database.
Fireface is designed to work with your Node.js server, and is configured using a service account, meaning your API doesn't need any special rules to access your Firebase database. Note that this also means Fireface and read, write, and delete any data, so you'll need to manage your own access control logic on your server.
Warning: don't use this library in a client-side web application. It's too exploitable.
Installation
Install as a local dependency:
npm install -S fireface
Setup
Fireface requires you to set up a Firebase project and a service account. When setting up your service account, make sure to download the credentials as a JSON file.
Once your project and account are set up, put your credentials JSON into your project, for example config/firebase/credentials.json
. It's recommended that you add this file to your .gitignore, since this file contains sensitive account information. If you need per-environment configuration, Marshall can help.
Usage
const ff = ; // Initialize Fireface/Firebaseff; // Get a refff; // Create a ref// WARNING: this will overwrite the entire ref.ff; // Update a refff; // Delete a refff; // Get a new unique ID for a refconst newUserId = ff;// Create a user with the new IDff; // Perform a query on a refff; // Update multiple refs at one timeff;
Versioning
To keep better organization of releases this project follows the Semantic Versioning 2.0.0 guidelines.
Contributing
Want to contribute? Follow these recommendations.