API Service of ImmoScout project (scrape, see results and organize them)
npm i
Copy .env-example
file to .env
and update values
Download or Copy and Paste the Service Account Key file from Google Cloud / Service Account or from another device where the project is already set up and paste it in the root as /google-cloud-service-account-key.json
.
- this authenticates this API to upload files to the Storage from your localhost.
Run npm start
Make a request with POSTMAN:
GET localhost:8080/properties
- Authorization:
"Bearer ${process.env.AUTH_TOKEN}"
(see in you environments)
creates property and uploads all body.images
(array of urls as strings / optional) as webp files into bucket.
The filenames of the uploads are replaced by incremental indices: 0.webp
, 1.webp
etc.
- Content-Type: application/json
- body:
{ scout_id: "...", images: ["...", ], ... }
- response:
- 201
{ "message": "Property created" }
upload a file into property (file into bucket / filename into DB: properties[i].uploads[j]
).
Gives filename a suffix if filename already exists.
- Content-Type: multipart/form-data
- body:
- :someFileName: File
- propertyId: number
- response:
- 201
{ "message": "uploaded to bucket..." }
- always on Branch
main
Build your container image using Cloud Build
# gcloud builds submit --tag gcr.io/{PROJECT_ID}/{SERVICE_NAME}
gcloud builds submit --tag gcr.io/tk-immoscout/immoscout-api
Deploy Container Image
# gcloud run deploy --image gcr.io/{PROJECT_ID}/{SERVICE_NAME} --platform managed
gcloud run deploy --image gcr.io/tk-immoscout/immoscout-api --platform managed
Deploy new revision of existing Service
gcloud run deploy SERVICE --image IMAGE_URL
# gcloud run deploy {SERVICE_NAME} --image {IMAGE_URL}
gcloud run deploy immoscout-api --image gcr.io/tk-immoscout/immoscout-api
- or in GCP Console (Browser) under Cloud Run > {Project} > Edit & Deploy new revision
more infos: https://cloud.google.com/run/docs/quickstarts/build-and-deploy
- Documentation: Google Cloud Storage: Node.js Client
- Related topic: medium.com: Image Upload With Google Cloud Storage and Node.js
- I didn't read the whole thing, but found it later on - and it seems to explain a lot which I went through