Firebase client and admin SDK wrapper for Adonis JS 4.0
npm install adonis-firebase --save
Create a file in app/config/firebase.js
and paste the code below by replacing it's values where necessary. Sample configuration can also be found in src/sample-config/firebase.js:
'use strict';
/*
|--------------------------------------------------------------------------
| Firebase
|--------------------------------------------------------------------------
|
| Provide details of firebase project
|
*/
module.exports = {
/*
|--------------------------------------------------------------------------
| Firebase Admin credentials key file
|--------------------------------------------------------------------------
*/
credentials: "",
/*
|--------------------------------------------------------------------------
| API key
|--------------------------------------------------------------------------
*/
apiKey: "",
/*
|--------------------------------------------------------------------------
| Auth
|--------------------------------------------------------------------------
*/
authDomain: "",
/*
|--------------------------------------------------------------------------
| Database
|--------------------------------------------------------------------------
*/
databaseURL: "",
/*
|--------------------------------------------------------------------------
| Hosting
|--------------------------------------------------------------------------
*/
storageBucket: ""
};
Also you need to add the provider to AdonisJS at app/bootstrap/app.js
:
const providers = [
...
'adonis-firebase/providers/Firebase',
'adonis-firebase/providers/FirebaseAdmin'
];
then you can simply call it from within controllers etc:
const Firebase = use('Firebase');
const FirebaseAdmin = use('FirebaseAdmin');