-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
359 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.vscode | ||
.DS_Store | ||
.env | ||
GoogleService-Info.plist | ||
GoogleService-Info.plist | ||
|
||
# self token | ||
firebase_auth_token.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,89 @@ | ||
# dfirestore | ||
|
||
a deno Firebase Firestore client #WIP do not use in production | ||
a deno Firebase Firestore REST client | ||
|
||
## Usage | ||
|
||
To get started with the package you can either setup the application with your tokens or authenticate with one of the helpers. | ||
After you authenticate you can freely use the REST client and your access tokens will rotate before they expire. | ||
|
||
### Configuration | ||
|
||
All configuration settings are optional if you are passing the options per request. | ||
|
||
```typescript | ||
import { | ||
setDatabase, | ||
setToken, | ||
setProjectID, | ||
firestore, | ||
setTokenFromServiceAccount, | ||
setTokenFromEmailPassword, | ||
} from "https://deno.land/dfirestore/mod.ts"; | ||
|
||
// set firebase db | ||
setDatabase("(default)"); | ||
/* | ||
* CONFIGURATION: Add authentication token for all request. Use one of the `setToken` methods below | ||
*/ | ||
|
||
// set firebase project | ||
// If GoogleService-Info.plist and gcloud installed on machine run to get service token | ||
setTokenFromServiceAccount(); | ||
// If Email and Password secret shared. optional params if using env variables | ||
setTokenFromEmailPassword( | ||
{ | ||
email: "someemail@something.com", | ||
password: "something", | ||
}, | ||
true // background refresh token before expiration | ||
); | ||
// Manually set authentication | ||
setToken("FIREBASE_AUTHORIZATION_TOKEN"); | ||
|
||
// set db | ||
setDatabase("(default)"); | ||
// set project | ||
setProjectID("myprojectid"); | ||
``` | ||
|
||
// set authorization | ||
setToken("FIREBASE_AUTHORIZATION_TOKEN"); | ||
### Main | ||
|
||
Use the REST client below via the following methods to perform CRUD operations. | ||
|
||
await firestore.getDocument("document/id"); | ||
```typescript | ||
import { firestore } from "https://deno.land/dfirestore/mod.ts"; | ||
|
||
await firestore.getDocument({ | ||
collection: "mycollection", | ||
id: "collection id", | ||
}); | ||
await firestore.getDocumentList("document"); | ||
await firestore.deleteDocument("document/id"); | ||
await firestore.updateDocument("document/id"); | ||
``` | ||
|
||
## ENV variables | ||
|
||
If you have a .env file the below env variables will be picked up. If you not you need to make sure you pass in the required params. | ||
|
||
### Project | ||
|
||
``` | ||
FIREBASE_DATABASE= | ||
FIREBASE_PROJECT_ID= | ||
``` | ||
|
||
### IAM admin auth - via email, password | ||
|
||
``` | ||
FIREBASE_PROJECT_KEY= | ||
FIREBASE_AUTH_EMAIL= | ||
FIREBASE_AUTH_PASSWORD= | ||
``` | ||
|
||
### Explicite authenticated user | ||
|
||
``` | ||
FIREBASE_TOKEN= | ||
``` | ||
|
||
### CI | ||
|
||
CI=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.