1 | [![Build Status](https://travis-ci.org/forest-fre/abstracted-client.svg?branch=master)](https://travis-ci.org/forest-fre/abstracted-client.svg?branch=master)
|
2 | [![Coverage Status](https://coveralls.io/repos/github/forest-fre/abstracted-client/badge.svg?branch=master)](https://coveralls.io/github/forest-fre/abstracted-client?branch=master)
|
3 | [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
|
4 |
|
5 | ![ ](./docs/images/abstracted-client.jpg)
|
6 |
|
7 | > A minimal abstraction over the Firebase client API
|
8 |
|
9 | ## Basic Usage
|
10 |
|
11 | Meant for frontend Javascript/Typescript apps which interact with Firebase's client API using the firebase client api.
|
12 |
|
13 | ```ts
|
14 | import DB, { IFirebaseConfig } from "abstracted-client";
|
15 | const config: IFirebaseClientConfig = {
|
16 | apiKey: "ATzaSyDuimhvBmcV1zeTl4m1MphOgWnzS16QhBM",
|
17 | authDomain: "my-app.firebaseapp.com",
|
18 | databaseURL: "https://my-app.firebaseio.com",
|
19 | projectId: "my-app",
|
20 | storageBucket: "my-app.appspot.com",
|
21 | messagingSenderId: "999999999999"
|
22 | };
|
23 | const db = new DB({ config });
|
24 | // Get a list of records
|
25 | const users = await db.getValue<IUser[]>("users");
|
26 | // Push a new value onto a list
|
27 | const company: ICompany = {
|
28 | name: "Acme",
|
29 | employees: 500
|
30 | };
|
31 | db.push<ICompany>("/companies", company);
|
32 | ```
|
33 |
|
34 | ### Authentication
|
35 |
|
36 | All of the authentication is done via the normal [Firebase API for Auth](https://firebase.google.com/docs/reference/js/firebase.auth) which is accessible as `auth` off the DB class:
|
37 |
|
38 | ```ts
|
39 | const db = new DB({ config });
|
40 | const auth = db.auth;
|
41 | ```
|
42 |
|
43 | ### Mocking
|
44 |
|
45 | 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.
|
46 |
|
47 | ## Documentation
|
48 |
|
49 | Since this library and **abstracted-admin** share a common implementation for most of their API surface you'll find the documentation here:
|
50 | [abstracted-admin](https://forest-fire.gitbooks.io/abstracted-client/content/)
|