testpackagejs v1.1.3
|>| Firework.js v1.1.1 |<|
Firework.js v1.1.1 is a Firebase Library, Helps To Write a Simple and Clean Back-End Firebase Code.
Features
Firework.js Library Supports
- Firebase Realtime Database
- Firebase Authentication
- Firebase Storage
- Firebase Admin SDK
- Firebase Notifications System
Installation
Use the package manager npm to install Firework.js.
npm i firework.js
You also can import firework library by including the script in your body tag
For production , you can use the latest optimized production version with: :
<!-- production version, optimized for size and speed -->
<script src="https://cdn.jsdelivr.net/npm/firework.js@1.1.1/firework.min.js"></script>
OR For Development, you can use the latest development version with:
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/firework.js@1.1.1/firework-dev.min.js"></script>
Install Firebase CLI and Deploy Functions
In order to use firebase admin sdk features or notifications system which both included with firework.js library , you need to install firebase cli and deploy firework functions to your project :
- First you need to install firebase tools globally:
npm install -g firebase-tools
- After that you need to install firebase functions & firebase Admin SDK in your project:
npm install firebase-functions@latest firebase-admin@latest --save
- Then you need to login to firebase console:
firebase login
- Init firebase functions in your project folder:
firebase init functions
- download the pre-built functions by firework.js, go to functions folder in your project and replace
./functions/index.js
file with index.js file which has the pre-built functions
- Install The Required Dependencies With NPM, First Make Sure You Are In The Functions Directory
./functions
npm install bcrypt unique-string --save
- Get Your serviceAccount.json File From Your Project Settings On Firebase Console And Paste it In
./functions
Directory, then Edit index.js File With Your Database URL And Require Your serviceAccount.json File In The Constant serviceAccount:
const serviceAccount = require("./serviceAccount.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<YOUR-DATABASE-URL>.firebaseio.com" /**>** REPLACE WITH YOUR DATABASE URL **<**/
});
- Final step,
Deploy
those pre-built functions to your firebase console:
firebase deploy --only functions
Secure Database Rules For Firework Admin And Auth Features, Go To Firebase Console And Update Your Realtime Database Rules:
{ "rules": { "$root": { ".read": true, // Change It As You Want ".write": true // Change It As You Want }, // Never Change The Following Rules For Your Users Security "FIREWORK": { "Users": { ".read": false, ".write": false }, "MasterDeveloperUID": { ".read": false, ".write": false }, "NotificationTokens": { ".read": "auth.uid !== null", ".write": "auth.uid !== null" } } } }
Notice : Notice : Don't Edit the firework.js pre-built functions unless you are advanced in firebase cloud functions service
Notice : To use notifications system you must download and include manifest and service-worker files to your main website directory, download them from here: manifest.json and firebase-messaging-sw.js.
Documentation
You Can Find Our Documentation and Useful Articles At Our Website Fireworkjs.tk
Conclusion.
By Using Firework.js , you can write simple code to manage your firebase project.
Built Based on ( Firebase 6.3.0 + JS ES6 ).
Fully Supported In All Browers ( Doesn't Support IE Browser )
Built By BroCoders Team (Hassan Ali) | All Rights Reserved 2019.