- cloud functions uses TypeScript
Firebase Functions Express Server for all my work
To initialize your project:
- Run firebase login to log in via the browser and authenticate the firebase tool.
- Go to your Firebase project directory.
- Run "firebase init functions". The tool gives you an option to install dependencies with npm. It is safe to decline if you want to manage dependencies in another way. If your new project is now showing up in the CLI list use "firebase -P init functions" to associate project folder with the right project from firebase.
-
create an express webapp (cors set headers etc): https://cloud.google.com/functions/docs/writing/http#writing_http_helloworld-nodejs
-
CORS and Authentication on Google Cloud Functions for Node: https://cloud.google.com/functions/docs/writing/http#writing_http_helloworld-nodejs
-
HTTP Function with authorisation (Firebase app users only) sample: https://github.com/firebase/functions-samples/tree/master/authorized-https-endpoint
-
npm cors module: https://www.npmjs.com/package/cors
-
understanding CORS in node: https://flaviocopes.com/cors/
- using cloud functions to make external API calls (outside google) is a chargeable feature. Needed to upgrade to Blaze Plan to support.
- uses the geokit npm package to hash lat/longs
- uses geofirestore to write and read from the db
- consider useing Geokit instead of geofirestore?