You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This client library is a simplified layer between your code and the Firebase REST API.
18
-
In the background it uses the Workers FETCH API to send HTTP requests to your Database.
8
+
# Workers Firebase RTDB Client
9
+
**Workers Firebase RTDB** is a [Firebase Realtime Database](https://firebase.google.com/docs/database) client library for use specifically with [Cloudflare Workers](https://developers.cloudflare.com/workers/) written in TypeScript.
19
10
20
11
## Functionality
21
-
- Easily create, edit, update, and delete json from your database
22
-
- Easy authentication with your database and it rules
23
-
- Supports conditional requests and ETag's
24
-
- Subscribe to data change events
25
-
### All in vanilla js with _no_ dependencies and in only **KB [for minified version]
12
+
- Easily **create, edit, update, and delete** json from your database
13
+
- Easy **authentication** with your database and its rules
14
+
- Supports **conditional requests**/ETag's
15
+
-**Follows Workers guidelines**, such as not mutating global state
16
+
-**Thorough documentation** and easy to understand functions
17
+
18
+
## Usage:
19
+
```
20
+
npm i --save @sharks-interactive/workers-firebase-rtdb-rest-client
if (response!='') returnnewResponse(response, {status: 200, statusText: 'OK'});
67
+
elsereturnnewResponse('Something went wrong', {status: 500, statusText: 'Internal Server Error'});
68
+
});
69
+
});
33
70
34
-
## dist /
35
-
- Contains js code
71
+
```
72
+
73
+
## Features:
74
+
-**.update()** updates data with a PATCH request
75
+
-**.push()** pushes data with a POST request
76
+
-**.write()** writes data with a PUT request
77
+
-**.read()** reads data with a GET request
78
+
-**.delete()** deletes data with a DELETE request
79
+
-**.appendGetEtagHeader()** appends to a list of headers the header required to get the ETag of data in the database
80
+
-**.appendEtagIfHeader()** appends to a list of headers the header required to submit a conditional ETag request to the database
81
+
-**tokenAuthentication** supports OAUTH token authentication as well as Firebase ID authentication
82
+
83
+
## Options (Required)
84
+
85
+
| Option | Type | Description |
86
+
| ------ | ---- | ----------- |
87
+
| databaseUrl | string | A string containing the base URL of your database. It **SHOULD** end in a ``/`` and it **MUST** start with ``https://``. See: https://firebase.google.com/docs/database/rest/start|
88
+
| authentication | string | Your authentication information. This should be a OAUTH token if ``tokenAuthentication`` is true, and an ID token if if is false. See: https://firebase.google.com/docs/database/rest/auth|
89
+
| tokenAuthentication | boolean | Whether the ``authentication`` string is an OAUTH token or Firebase ID. See: https://firebase.google.com/docs/database/rest/auth
90
+
91
+
## How it works:
92
+
This client library is a simplified layer between your code and the Firebase REST API.
93
+
In the background it uses the Workers FETCH API to send HTTP requests to your Database.
94
+
95
+
**Read the wiki for extra documentation.**
36
96
37
97
Project created and maintained by Sharks Interactive.
38
98
@@ -42,3 +102,6 @@ Project created and maintained by Sharks Interactive.
42
102
### Code Style:
43
103
- Continious Integration will handle formatting for you
44
104
- Use ESLINT locally to catch errors pre-pr
105
+
106
+
## Acknowledgements:
107
+
**README.MD and general SDK structure, styling, practices etc, modelled after and taken from the excellent [Toucan-JS](https://github.com/robertcepa/toucan-js)**
0 commit comments