{"id":19140099,"url":"https://github.com/sharks-interactive/workers-firebase-rtdb-rest-client","last_synced_at":"2025-07-12T01:37:01.555Z","repository":{"id":45934326,"uuid":"405245693","full_name":"Sharks-Interactive/workers-firebase-rtdb-rest-client","owner":"Sharks-Interactive","description":"🔥Firebase Realtime-Database client for Cloudflare Workers.","archived":false,"fork":false,"pushed_at":"2023-03-14T01:53:28.000Z","size":40,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"prod","last_synced_at":"2025-05-06T23:16:24.622Z","etag":null,"topics":["client-library","cloudflare-workers","firebase","firebase-database"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sharks-Interactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-11T00:29:51.000Z","updated_at":"2023-10-24T18:49:52.000Z","dependencies_parsed_at":"2025-03-21T14:12:35.206Z","dependency_job_id":null,"html_url":"https://github.com/Sharks-Interactive/workers-firebase-rtdb-rest-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharks-Interactive%2Fworkers-firebase-rtdb-rest-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharks-Interactive%2Fworkers-firebase-rtdb-rest-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharks-Interactive%2Fworkers-firebase-rtdb-rest-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharks-Interactive%2Fworkers-firebase-rtdb-rest-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sharks-Interactive","download_url":"https://codeload.github.com/Sharks-Interactive/workers-firebase-rtdb-rest-client/tar.gz/refs/heads/prod","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782835,"owners_count":21803410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-library","cloudflare-workers","firebase","firebase-database"],"created_at":"2024-11-09T07:16:14.557Z","updated_at":"2025-05-06T23:16:31.919Z","avatar_url":"https://github.com/Sharks-Interactive.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align='center'\u003e\n  \u003cimg src=\"https://i.imgur.com/7svMXLi.png\" /\u003e\n\u003c/p\u003e\n\n![npm version](https://img.shields.io/npm/v/@sharks-interactive/workers-firebase-rtdb-rest-client)\n![npm downloads](https://img.shields.io/npm/dm/@sharks-interactive/workers-firebase-rtdb-rest-client)\n![npm types](https://img.shields.io/npm/types/@sharks-interactive/workers-firebase-rtdb-rest-client)\n\n\n# Workers Firebase RTDB Client\n**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.\n\n## Functionality\n- Easily **create, edit, update, and delete** json from your database\n- Easy **authentication** with your database and its rules\n- Supports **conditional requests**/ETag's\n- **Follows Workers guidelines**, such as not mutating global state\n- **Thorough documentation** and easy to understand functions \n\n## Usage:\n```\nnpm i --save @sharks-interactive/workers-firebase-rtdb-rest-client\n```\n\n## Quick Examples:\n#### Writing Data\n```ts\nimport Database from '@sharks-interactive/workers-firebase-rtdb';\n\naddEventListener('fetch', (event) =\u003e {\n  const db = new Database({\n    databaseUrl: 'https://example-db-default-rtdb.firebaseio.com/',\n    authentication: 'bearer ya29.[YOUR-OAUTH-TOKEN-HERE]',\n    tokenAuthentication: true,\n  });\n  event.respondWith(async () =\u003e {\n    const success = await db.update(\n        'user/settings',\n        JSON.stringify({theme: 'dark'}),\n        true,\n        new Headers(), // Optional\n    );\n\n    if (success) return new Response('Ok', {status: 200, statusText: 'OK'});\n    else return new Response('Something went wrong', {status: 500, statusText: 'Internal Server Error'});\n  });\n});\n\n```\n\n### Reading Data\n```ts\nimport Database from '@sharks-interactive/workers-firebase-rtdb';\n\naddEventListener('fetch', (event) =\u003e {\n  const db = new Database({\n    databaseUrl: 'https://example-db-default-rtdb.firebaseio.com/',\n    authentication: 'bearer ya29.[YOUR-OAUTH-TOKEN-HERE]',\n    tokenAuthentication: true,\n  });\n  event.respondWith(async () =\u003e {\n    const response = await db.read(\n        'user/settings',\n        true,\n        new Headers(), // Optional\n    );\n\n    if (response != '') return new Response(response, {status: 200, statusText: 'OK'});\n    else return new Response('Something went wrong', {status: 500, statusText: 'Internal Server Error'});\n  });\n});\n\n```\n\n## Features:\n- **.update()** updates data with a PATCH request\n- **.push()** pushes data with a POST request\n- **.write()** writes data with a PUT request\n- **.read()** reads data with a GET request\n- **.delete()** deletes data with a DELETE request\n- **.appendGetEtagHeader()** appends to a list of headers the header required to get the ETag of data in the database\n- **.appendEtagIfHeader()** appends to a list of headers the header required to submit a conditional ETag request to the database\n- **tokenAuthentication** supports OAUTH token authentication as well as Firebase ID authentication\n\n## Options (Required)\n\n| Option | Type | Description |\n| ------ | ---- | ----------- |\n| 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 |\n| 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 |\n| tokenAuthentication | boolean | Whether the ``authentication`` string is an OAUTH token or Firebase ID. See: https://firebase.google.com/docs/database/rest/auth\n\n## How it works:\nThis client library is a simplified layer between your code and the Firebase REST API.\nIn the background it uses the Workers FETCH API to send HTTP requests to your Database.\n\n**Read the wiki for extra documentation.**\n  \nProject created and maintained by Sharks Interactive.\n  \n### Developing:\n  - Commit to ``staging`` and pr to ``prod`` for changes\n\n### Code Style:\n  - Continious Integration will handle formatting for you\n  - Use ESLINT locally to catch errors pre-pr\n\n## Acknowledgements:\n**README.MD and general SDK structure, styling, practices etc, modelled after and taken from the excellent [Toucan-JS](https://github.com/robertcepa/toucan-js)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharks-interactive%2Fworkers-firebase-rtdb-rest-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharks-interactive%2Fworkers-firebase-rtdb-rest-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharks-interactive%2Fworkers-firebase-rtdb-rest-client/lists"}