関数の削除方法
- 削除コマンドで明示的に削除する方法
- デプロイ時に存在しない関数を削除する方法
https://firebase.google.com/docs/functions/manage-functions
削除コマンドを実行する
# Delete all functions that match the specified name in all regions.
$ firebase functions:delete myFunction
# Delete a specified function running in a specific region.
$ firebase functions:delete myFunction --region us-east-1
# Delete more than one function
$ firebase functions:delete myFunction myOtherFunction
# Delete a specified functions group.
$ firebase functions:delete groupA
# Bypass the confirmation prompt.
$ firebase functions:delete myFunction --force
index.js から該当する関数を削除しておくと deploy 時に削除確認が行われる。
$ firebase deploy --only functions
$ firebase deploy --only functions:helloWorld
TypeScript使用時に Cannot find name ‘xxx’ とでて deploy エラーになる。
以下のような構成の場合、TypeScript の挙動で @types を親ディレクトリの node_module まで見に行ってしまう。
http://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types
--- node_modules
|
|---- functions
| |
| |- node_modules
| |- tsconfig.json
|
|- tsconfig.json
対応としては functions/tsconfig.json に typeRoot を指定する。
{
"compilerOptions": {
"typeRoots" : ["node_modules/@types"]
}
}
アップロード先のリージョンを指定する
デフォルトだと us-central1
に関数が作成される。
- https://firebase.google.com/docs/functions/manage-functions
- https://firebase.google.com/docs/functions/locations
変更する場合は以下のように修正する。
日本語ドキュメントだと複数リージョンを指定できるかのごとく書かれていたが、 2018/8 現在では1リージョンしか指定できないので注意。
import * as functions from 'firebase-functions';
// export const helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
export const helloWorld = functions
.region("asia-northeast1")
.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});