- In the directory
functions/
- Update
firebaseandfirebase-adminSDK. Since there are some changes in the import method, we man need more time to update the package. If it is possible, change the import method from CommonJS to ESM module. - Update
apollo-serverfrom 2 to 3. But it seems that v3 doesn't support subscription natively. So we may need some time to investigate how to make subscription function normally.
- First you need to install all the necessary packages. Run the following command in the directory
functions:npm install
- 在run之前,要先下載專案的 service accounts file,並設定環境變數
GOOGLE_APPLICATION_CREDENTIALS。參考這裡 - 設定好之後,切換到
[...]/SmartCampus/functions/graphql_server底下,透過以下指令開啟npm run localstart
- Prequiste: You need to have
docker+docker-composeto be installed. - In the directory, run the following command:
docker compose up - We don't push the image to Dockerhub, so the image would be built locally.
- The firestore emulator data would be store in the directory
./emulator-datawhen you exit. And it would be import to the firestore emulator when you start the container next time. If you want to empty the firestore emulator, just delete the content in the directory.- You must have
./emulator-datadirectory before set up container, or the container would crash.
- You must have
- If you want to test the auth functionality, you can see here. The port(9099) already be exposed. Make sure you connect to the auth service using
0.0.0.0:9099rather thanlocalhost:9099 - Connect to the service by
0.0.0.0:<port>rather thanlocalhost:<port>(It depends on Windows or Mac)
- 在最一開始想先安裝firebase-tools和initialize,參考get started step 2 and 3
- 完成更動後,跑下面的指定把更動部署到cloud function上
firebase deploy --only functions
- Programming language: node.js v14
- API framework: Apollo graphql server
- Database: firebase firestore + firebase Admin SDK
- Deploy on: GCP cloud run
