Open3

firebase/GCP関係

tukuyotukuyo

functionsのソースや環境変数を見たい時

urlにアクセスして、対象プロジェクト、対象functionを見る

https://console.cloud.google.com/functions/list?project=_
tukuyotukuyo

Firebase Cloud Messaging のエラーを吐いた時

third-party-auth-error

errorInfo: {
    code: 'messaging/third-party-auth-error',
    message: 'Auth error from APNS or Web Push Service'
  },

解決法

APNs keyが期限切れ、もしくは、見つからない時に発生するエラー
firebaseコンソールにもう一度上げ直しで治る

参考

https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

tukuyotukuyo

functionsでのAPIキーなどの保存方法

Google Secret Manager を使用する

onCall, onRequest

const API_KEY = defineSecret('API_KEY');

export test-func = onCall((
  {
    secrets: ['API_KEY'],
  },
  async (req: CallableRequest<T>) => {
    const key = ApiKey.value();
  }
)

onDocumentCreated, onDocumentUpdated, onDocumentDeleted, onDocumentWritten

const API_KEY = defineSecret('API_KEY');

export test-func = onDocumentCreated((
  {
    document: 'doc/{docId}'
    secrets: ['API_KEY'],
  },
  async (event) => {
    const key = ApiKey.value();
  }
)

トップにdefineSecretを置く理由

デプロイする時に環境変数を使用している場合、CLI上でSecretManagerに存在しない時に聞いてくれる
登録していたらその限りではない