Upgrade to Pro — share decks privately, control downloads, hide ads and more …

firebase cloud functions

firebase cloud functions

Firebase and cloud functions talk given at Google dev fest mumbai 2017

Avatar for Nitish Phanse

Nitish Phanse

October 28, 2017

Other Decks in Technology

Transcript

  1. Cloud Functions • Code hosted in the cloud • Node

    JS environment v6.9.1 • Connects to other google services like firebase. (req, res) => …
  2. Use cases of Firebase CFs • Real time database sanitization

    • Integrate with third party APIs • Analytics service • Cloud messaging
  3. Function Triggers • Realtime Database / Firestore Triggers • Firebase

    Authentication Triggers • Cloud Storage Triggers • HTTP Triggers • Firebase Analytics Triggers
  4. Database trigger • onWrite , onCreate, onUpdate • Path specific

    • Event data object (event.data) OOPS !!!
  5. Authentication trigger • New user signs up / signs in

    • Event data object (event.data)
  6. HTTPS trigger • Each function name => Url • GET,

    POST, PUT, DELETE • Terminate with send(), redirect(), end().
  7. Putting it all together Sign up User 1 ref(‘/users’) User

    2 ref(‘/fcmtokens’) push to analytics
  8. Putting it all together Sign up User 1 ref(‘/users’) User

    2 ref(‘/messages’) ref(‘/fcmtokens’) push to analytics
  9. Putting it all together Sign up User 1 ref(‘/users’) User

    2 ref(‘/messages’) Fetch Tokens Send notifications to all Users ref(‘/fcmtokens’) push to analytics
  10. The pain • Deployment takes time • Realtime logs are

    delayed in production • Accidental tight coupling