VeryGoodOpenSource / dart_frog

A fast, minimalistic backend framework for Dart 🎯
https://dartfrog.vgv.dev
MIT License
1.86k stars 148 forks source link

feat: support cloud event deserialization out of the box #1319

Open a-wallen opened 7 months ago

a-wallen commented 7 months ago

Description

Support for context.request.pubsub() similar to context.request.json() immediately.

This may work well as a package, but to be honest, I am not sure what the best way is.

I have a few services that I've deployed to cloud run that respond to various Eventarc events.

Would be nice to have this functionality out of the box.

Requirements

jhuckabee commented 7 months ago

I like the thinking behind this. Two questions for you @a-wallen...

  1. What do you envision as the return type of the two methods listed in your requirements? Is that an object from google_cloudevents_dart? For context.request.firestoreDocument() my mind immediately goes to DocumentEventData (defined here).
  2. Does this also imply that we'd have essentially a method per system? e.g. context.request.storage for a Cloud Storage events, context.request.alloydb for AlloyDB events, etc.
a-wallen commented 7 months ago

What do you envision as the return type of the two methods listed in your requirements? Is that an object from google_cloudevents_dart? For context.request.firestoreDocument() my mind immediately goes to DocumentEventData (defined here).

Yes, that would be the idea.

Does this also imply that we'd have essentially a method per system? e.g. context.request.storage for a Cloud Storage events, context.request.alloydb for AlloyDB events, etc.

Yes, we would support all cloud events.

This may be best suited as an extension library.