Skip to content

Commit

Permalink
feat(firestore): init client on Cloud Functions and Cloud Run service
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdbd committed Sep 13, 2022
1 parent d1c5161 commit 168a475
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/firestore-utils/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export const firestore = (options: Options = DEFAULT_OPTIONS) => {
details.push(`process.env.CLOUD_RUN_JOB not set`)
}

if (process.env.FUNCTION_SIGNATURE_TYPE) {
return new Firestore()
} else {
details.push(`process.env.FUNCTION_SIGNATURE_TYPE not set`)
}

if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
return new Firestore({
keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS
Expand All @@ -45,6 +51,12 @@ export const firestore = (options: Options = DEFAULT_OPTIONS) => {
details.push(`process.env.GOOGLE_APPLICATION_CREDENTIALS not set`)
}

if (process.env.K_SERVICE) {
return new Firestore()
} else {
details.push(`process.env.K_SERVICE not set`)
}

const env_key =
options && options.env_key_json_string
? options.env_key_json_string
Expand Down

0 comments on commit 168a475

Please sign in to comment.