Weather Journey Image API is a RESTful API that generates images based on the weather conditions of a location. It uses the OpenAI API to generate images based on the weather conditions of a location. The API is built using NestJS and is deployed on Google Cloud Run.
This project requires the following:
- Google Cloud Platform account
- OpenAI API Key
- Firebase Admin SDK Key -> Firebase Auth and Firestore
$ npm install
export NODE_ENV=development
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Start the Firebase Emulator and generate a JWT token for testing.
Reference : https://stackoverflow.com/a/66343248/19101705
$ npm run firebase:emulator
$ curl -X POST \ 'http://127.0.0.1:9099/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=key' \
-H 'content-type: application/json' \
-d '{ "email":"[email protected]", "password":"alicealice", "returnSecureToken":true }'
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
# build
docker build -t europe-west1-docker.pkg.dev/weatherapp-journey/weather-generation-api/generation-api:0.0.1 --platform linux/amd64 .
# push
docker push europe-west1-docker.pkg.dev/weatherapp-journey/weather-generation-api/generation-api:0.0.1
# deploy
gcloud run deploy weather-generation-api \
--image europe-west1-docker.pkg.dev/weatherapp-journey/weather-generation-api/generation-api:0.0.1 \
--platform managed \
--region europe-west1 \
--allow-unauthenticated \
--min-instances 1 \
--max-instances 2 \
--memory 512Mi \
--cpu 1 \
--port 3000 \
--set-env-vars "OPENAI_API_KEY=YOUR_KEY" \
--service-account=weather-generation-api-runner@weatherapp-journey.iam.gserviceaccount.com