sails-firebase
Sails.js/Waterline adapter for Firebase.
Warning
This adapter is still under active development and in no manner is advised using it in a production environment.
Check the project issues board for announcements, bug reports, upcoming features and discussions.
Only mandatory semantic interface methods were implemented. The next steps is bringing queryable and associations to life asap.
Introduction
Overview
The Firebase Realtime Database synchronized in realtime to every connected client.
It allows you build cross-platform apps with our iOS and Android, all of your clients share one Realtime Database instance and automatically receive updates with the newest data.
However the current Firebase architecture force the developers to implement a lof of business logic as part of the mobile applications, leading to some side-effects:
- Business logic code duplication among Android, iOS, Windows and all mobile platforms
- Due version fragmentation, business logic is affected by apps being (not) updated.
Sails.js and Waterline as Mobile Orchestrator
This Waterline Firebase Adapter provides missing piece to Sails.js become a mobile orchestrator. The server application read and writes directly into Firebase, which updates all mobile devices connected to it in realtime; just like a message passing distributed system.
Configure and Install
Dependencies
At your Sails.js project, install the adapter library:
$ npm install sails-firebase --save
Configure
Create an application at Firebase admin console, then access the project settings menu:
https://console.firebase.google.com/project/<YOUR PROJECT NAME>/settings/general/
Go to the account services menu and create download a server private key, which will contain valid credential
and databaseUrl
.
You will add an adapter
atribute and copy it into connection.js
configuration file:
// ./config/connections.js
module.exports.connections = {
firebase: {
adapter: 'sails-firebase',
credential: {
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "<YOUR EMAIL CLIENT>",
"client_id": "<YOUR CLIENT ID>",
"client_x509_cert_url": "<YOUR CLIENT X509 CERTIFICATE>",
"private_key": "<YOUR PRIVATE KEY>",
"private_key_id": "<YOUR PRIVATE KEY ID>",
"project_id": "<YOUR PROJECT ID>",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"type": "service_account",
},
databaseURL: "https://<YOUR PROJECT NAME>.firebaseio.com",
}
};
and also configure your model:
// ./config/models.js
module.exports.models = {
'connection': 'firebase'
};
Contributing
If you wish to contribute to Waterline Firebase Adapter
, first we would like to thank you for dedicating your time on this project.
Before create a pull request, keep some things in mind:
- Be polite with other community developers.
- Run the integration tests locally and be sure they pass.
- Keep the code style.
- Create awesome commit messages (use emojis and read Udacity Git Style Guide)
The adapter currently provides only semantic inteface. If you are submitting other interfaces, add it to the package.json
file:
{
"waterlineAdapter": {
"type": "sails-firebase",
"interfaces": [
"semantic"
],
"waterlineVersion": "~0.12.1"
}
}