From 1b33854ce8162bb6913ab7122fd909b99a80e29c Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Wed, 4 May 2022 10:39:17 +0900 Subject: [PATCH 1/3] =?UTF-8?q?esa=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E5=9E=8B=E3=82=92=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 5f985212..8a7bbee4 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -52,6 +52,12 @@ export type EsaTags = { tags: Tag[] } +// ref: https://docs.esa.io/posts/102#%E3%82%A8%E3%83%A9%E3%83%BC%E3%83%AC%E3%82%B9%E3%83%9D%E3%83%B3%E3%82%B9 +type EsaErrorResponse = { + error: string; + message: string; +} + function transformTitle(oldTitle: string, newTitle: string): string { const result = Array.from(new Set(oldTitle.split(/,\s?|、/).concat(newTitle.split(/,\s?|、/)))); if (JSON.stringify(result) === JSON.stringify(['日報'])) { @@ -86,7 +92,8 @@ async function createOrUpdatePost( }, }).then((res: AxiosResponse) => { return res.data; - }).catch((err: AxiosError) => { + }).catch((err: AxiosError) => { + err.response?.statusText throw new functions.https.HttpsError('invalid-argument', `${err.response?.data.error}: ${err.response?.data.message}`); }); } @@ -102,7 +109,7 @@ async function createOrUpdatePost( }, }).then((res: AxiosResponse) => { return res.data; - }).catch((err: AxiosError) => { + }).catch((err: AxiosError) => { throw new functions.https.HttpsError('invalid-argument', `${err.response?.data.error}: ${err.response?.data.message}`); }); } From 53551306f27cf710262728738a0825f2602d5739 Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Wed, 4 May 2022 10:42:29 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BA=8B=E5=89=8D=E3=81=ABbuild=E3=81=A7?= =?UTF-8?q?=E3=81=93=E3=81=91=E3=81=A6=E3=81=84=E3=82=8B=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=82=92=E6=A4=9C=E7=9F=A5=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=ABgithub=20action=E3=82=92=E5=AE=9A=E7=BE=A9?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../check_firebase_cloud_function.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/check_firebase_cloud_function.yaml diff --git a/.github/workflows/check_firebase_cloud_function.yaml b/.github/workflows/check_firebase_cloud_function.yaml new file mode 100644 index 00000000..1fa403fe --- /dev/null +++ b/.github/workflows/check_firebase_cloud_function.yaml @@ -0,0 +1,18 @@ +name: Firebase Cloud Function部分の確認 + +on: [push] + +jobs: + check_firebase_hosting: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '12' + - run: npm install + - run: npm install + working-directory: ./functions + - run: npm --prefix functions run lint + - run: npm --prefix functions run build From 2f5fce32ed8a7e9bb3bdec6f6663fd5b83e7d6b1 Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Wed, 4 May 2022 10:46:25 +0900 Subject: [PATCH 3/3] unused --- functions/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index 8a7bbee4..e6d60c69 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -93,7 +93,6 @@ async function createOrUpdatePost( }).then((res: AxiosResponse) => { return res.data; }).catch((err: AxiosError) => { - err.response?.statusText throw new functions.https.HttpsError('invalid-argument', `${err.response?.data.error}: ${err.response?.data.message}`); }); }