Skip to content

Commit

Permalink
feat: init typescript example (#8)
Browse files Browse the repository at this point in the history
* feat: init typescript example

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* Update typescript.ts
  • Loading branch information
grant committed Aug 7, 2020
1 parent 28e46fd commit b6280b1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Import types
import {MessagePublishedData} from '../src/google/events/cloud/pubsub/v1/data_pb';

// Annotate objects with types
const pubsubData: MessagePublishedData.AsObject = {
message: {
data: atob('Pub/Sub data'),
attributesMap: undefined,
messageId: 'my-message-id'
},
subscription: 'projects/my-project/subscriptions/cre-us-central1-pubsub-trigger-5-sub-000'
}

console.log(pubsubData.message.data);

0 comments on commit b6280b1

Please sign in to comment.