1 | [![Build Status](https://travis-ci.org/forest-fre/abstracted-admin.svg?branch=master)](https://travis-ci.org/forest-fre/abstracted-admin.svg?branch=master)
|
2 | [![Coverage Status](https://coveralls.io/repos/github/forest-fre/abstracted-admin/badge.svg?branch=master)](https://coveralls.io/github/forest-fre/abstracted-admin?branch=master)
|
3 | [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
|
4 |
|
5 | ![ ](./docs/images/abstracted-admin.jpg)
|
6 | > A minimal abstraction over the Firebase ADMIN API
|
7 |
|
8 | ## Basic Usage
|
9 | Meant for backend nodejs micro-services which interact with Firebase's Admin API using a "service policy" to authenticate.
|
10 |
|
11 | ```js
|
12 | import DB from 'abstracted-admin';
|
13 | const db = new DB();
|
14 | // Get a list of records
|
15 | const users = await db.getValue<IUser[]>('users');
|
16 | // Push a new value onto a list
|
17 | const company: ICompany = {
|
18 | name: "Acme",
|
19 | employees: 500
|
20 | }
|
21 | db.push<ICompany>('/companies', company);
|
22 | ```
|
23 |
|
24 | ### Authentication
|
25 | All of the Authentication is done transparently as soon as requests are made to the database. In order for this library to achieve this it will need the following environment variables set:
|
26 |
|
27 | - `FIREBASE_SERVICE_ACCOUNT` - this should be a URI-Encoded string of the JSON data which you exported at the time you created a Service Account on Google.
|
28 | - `FIREBASE_DATA_ROOT_URL` - comes from the Firebase console and dictates which DB to connect to
|
29 |
|
30 | ### Mocking
|
31 | This library supports simple redirecting of all operations to the `firemock` mocking library; see [related projects](docs/related.md)) and the ["Mocking" section](docs/mocking.md) of the docs here for more details. In cases where mocking is being used, authentication (and security rights for paths) are not supported and therefore the above ENV variables are not required.
|
32 |
|
33 | ## Documentation
|
34 |
|
35 | [Gitbook](https://forest-fire.gitbooks.io/abstracted-admin/content/)
|