google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

Add support for non-Node worker environments

Open iBobik opened this issue 1 year ago • 1 comments

What would you like to see in the library?

Support for non-NodeJS runtimes like Cloudflare workers. Currently this library fails to compile for Cloudflare when using Nitro framework. In other workers it could just fail in runtime.

Describe alternatives you've considered

It works to use this library only for Typescript types and send requests the other way:

import type { protos } from '@googlemaps/places'

const data = await $fetch<protos.google.maps.places.v1.IAutocompletePlacesResponse>('https://places.googleapis.com/v1/places:autocomplete', {
  method: 'POST',
  body: {
    input,
    languageCode: language,
    sessionToken,
    locationBias: { rectangle: {
      low: { latitude: businessArea.minLat, longitude: businessArea.minLng },
      high: { latitude: businessArea.maxLat, longitude: businessArea.maxLng },
    } },
  } as protos.google.maps.places.v1.IAutocompletePlacesRequest,
  headers: { 'X-Goog-Api-Key': googleMapsApiKey },
})

iBobik avatar Nov 05 '24 16:11 iBobik

Please do this

OultimoCoder avatar Nov 06 '24 14:11 OultimoCoder