firebase-connector
v1.0.5
Published
Firebase Connector - simple javascript (ES6) library to create connection with Firebase.
Downloads
5
Maintainers
Readme
Firebase Connector
Firebase Connector - simple javascript (ES6) library to create connection with Firebase.
Install
Just copy & paste to your command line
npm i firebase-connector --save
Repo
https://github.com/michalstol/firebase-connector/
Start
Firebase Connector is simple to use.
extend your class like this:
class App extends FirebaseConnector { }
pass the firebase config like this:
constructor() { super({ apiKey: "your-api-key", authDomain: "your-app.firebaseapp.com", databaseURL: "https://your-app.firebaseio.com", projectId: "your-app", storageBucket: "your-app.appspot.com", messagingSenderId: "your-app-sender" }); }
How generate this config you can found on this site -> Firebase Console Page
use specific method & fun! :)
Variables
This library give you only few method but you can use all Firebase method. How? Just using this useful variables:
// Firebase initialize
this.app
// Firebase auth
this.auth
// Firebase database
this.db
// Firebase storage
this.storage
Method
Just few method to use Firebase
SignIn
In your extended class just call and past 2 variables:
this.signInFirebase(email, pass)
You can catch callback using this method:
this.eventSignIn(user) {
// your code
}
this.eventSignInError(data) {
// your code
}
this.eventSignOut(user) {
// your code
}
GetDB
In your extended class just call and past 1 variable:
this.getDBRef(pathOfRef);
This method return object from your ref.
GetStorage
In your extended class just call and past 1 variable:
this.getStorageRef(pathOfStorage);
This method return object from your ref.
SaveDB
In your extended class just call and past 2 variables:
this.saveDBFirebase(pathOfRef, data);
UploadFiles
In your extended class just call and past object with 3 variables.
Warning - for now you can only upload file using data_url - eg. image base64.
const newFile = {
path: 'pathOfStorage',
file: 'userFile',
name: 'fileName'
};
this.uploadFilesByDataUrl(newFile);
This method have 2 callbacks:
During transfer
this.eventTransferDuring(data) {
// your code
}
During transfer
this.eventTransferComplete(event) {
// your code
}
Test
You can also make a test. Upload repo from this place. Next install all package:
npm install
Change config in test.js and build app using this commend:
npm run test
Last step is run from /test folder test.html. Now you can signUp and build test app.