-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New samples for Cloud Functions docs #132
Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4a1c20d
Add HTTP Cloud Function.
jmdobry b981fe4
Add more GCF http samples.
jmdobry de7c2ba
Change string
jmdobry 79ae033
Added promise sample.
jmdobry eec53f6
Add background functions tests.
jmdobry 3b2c6fc
Added more GCF tests.
jmdobry 85ec9ba
Fix readme and make test work in Node 0.12
jmdobry e27e128
Changed helloworld to camel case (#133)
jasonpolites 2b57ec0
Changed helloworld to camel case (#134)
jasonpolites 6ea5b95
Add BigQuery processing to SendGrid sample (still needs more tests).
jmdobry 0493fa3
Add basic auth check.
jmdobry d278df7
Add fix for property names
jmdobry 6a070cc
Make fixNames method recursive.
jmdobry 94913d1
Changed helloworld to camel case (#136)
jasonpolites cf1f7ff
Add small helloGET sample.
jmdobry 67f1810
Tweak some hello world samples.
jmdobry b1cfb26
Finish sendgrid unit tests.
jmdobry 48f87cd
Add missing readme link.
jmdobry f69a769
Update comment.
jmdobry b2eb9d9
Make sure a response gets sent.
jmdobry d5a684e
Made requested fixes.
jmdobry 7633d3d
Final fixes.
jmdobry 78540e0
Couple fixes to fix test flakiness.
jmdobry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add fix for property names
- Loading branch information
commit d278df75e8199af60c03e2d100b35b6953cda3b2
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,22 @@ function verifyWebhook (authorization) { | |
} | ||
// [END verifyWebhook] | ||
|
||
function fixNames (obj) { | ||
if (Array.isArray(obj)) { | ||
obj.forEach(fixNames); | ||
} else if (obj && typeof obj === 'object') { | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
var fixedKey = key.replace('-', '_'); | ||
if (fixedKey !== key) { | ||
obj[fixedKey] = obj[key]; | ||
delete obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// [START webhook] | ||
/** | ||
* Receive a webhook from SendGrid. | ||
|
@@ -198,6 +214,8 @@ exports.sendgridWebhook = function sendgridWebhook (req, res) { | |
|
||
var events = req.body || []; | ||
|
||
fixNames(events); | ||
|
||
// Generate newline-delimite JSON | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
// See https://cloud.google.com/bigquery/data-formats#json_format | ||
var json = events.map(function (event) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you documented fixNames above, but a small comment on why you're calling this would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done