Backend for Windy 10v10ai with Firebase
- Firebase
- Hosting
- Functions
- Firestore Database
- NextJS
- Java
- Node v22
- Recommend install node use nvm
# set/update node version
nvm install
nvm alias default $(cat .nvmrc)# firebase setting
npm install -g firebase-tools
firebase login
firebase use windy10v10ai
# setup package
npm install
# web setting
firebase experiments:enable webframeworks# Setup gcloud authentication (need to do first time)
gcloud auth login
gcloud config set project windy10v10ai# download data from storage
rm -rf firestore-backup
mkdir firestore-backup
gsutil -m cp -r "gs://windy10v10ai.appspot.com/firestore-backup/20250928/*" firestore-backupnpm run start# REPL
(cd api && npm run start -- --entryFile repl)
# unit tests
(cd api && npm run test)
# e2e tests (need stop firebase emulator)
(cd api && npm run test:e2e)Tips: If debug or e2e test not working with address already used error, kill nodejs process by pkill -f node, or try to restart winnat
net stop winnat
net start winnat
- Firebase Hosting: http://localhost:5000/api/
- Function (Not used): http://localhost:5001/windy10v10ai/asia-northeast1/client/api/
- Firebase Emulator: http://localhost:4000/
- Debug end points: http://localhost:3001/api/
- OpenAPI Document (Swagger): http://localhost:3001/api-doc
- Nextjs Web: http://localhost:3000/
More usage details, including configuration, authentication, and example code, please refer to API Guide.
Github Action will deploy automatically when push to main branch.
- main: Deploy Firebase Functions and Hosting
- Deploy all
firebase deploy
- Deploy part
# Deploy specific function
firebase deploy --only functions:client
firebase deploy --only functions:admin
firebase deploy --only functions:scheduledOrderCheck
# Deploy all function
firebase deploy --only functions
# Deploy hosting only
firebase deploy --only hosting
# Deploy function and hosting
firebase deploy --only functions,hosting- Create env in secret manager
- Set function run with secrets in index.ts
- Use secrets as
process.env.SECRET_NAMEin code
https://console.cloud.google.com/firestore/databases/-default-/import-export?project=windy10v10ai
- Update package.json
# install tool
`npm install -g npm-check-updates`
# cd to dir
cd api
# update package.json
ncu -u
# update package-lock.json
npm update- gcloud cli
curl -H "Authorization: bearer $(gcloud auth print-identity-token)" https://asia-northeast1-windy10v10ai.cloudfunctions.net/admin/api
## Get token
echo $(gcloud auth print-identity-token)Import api/swagger-spec.yaml to postman with variable baseUrl : https://asia-northeast1-windy10v10ai.cloudfunctions.net/admin
firebase ext:install firebase/firestore-bigquery-exportor Edit firebase.json and create extensions/firestore-bigquery-export-xxx.env
"extensions": {
"firestore-bigquery-export-xxx": "firebase/firestore-bigquery-export@0.1.54"
}firebase deploy --only extensionsSetup gcloud default auth
gcloud auth application-default loginRun import command
sh ./extensions/import-firestore-to-bigquery.shCreate schema file table_name_schema.json and run command.
sh ./extensions/generate-schema-views.sh