-
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
Added promise sample.
- Loading branch information
commit 79ae03384417566caca49ee675834eb8cf63805a
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2016, Google, Inc. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
// [START helloworld] | ||
/** | ||
* Background Cloud Function. | ||
* | ||
* @param {Object} context Cloud Function context. | ||
* @param {Object} data Request data, provided by a trigger. | ||
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. Document that data expects a 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 |
||
*/ | ||
exports.helloworld = function helloworld (context, data) { | ||
if (data.message === undefined) { | ||
// This is an error case, "message" is required | ||
context.failure('No message defined!'); | ||
} else { | ||
// Everything is ok | ||
console.log(data.message); | ||
context.success(); | ||
} | ||
}; | ||
// [END helloworld] | ||
|
||
// [START helloPromise] | ||
var request = require('request-promise'); | ||
|
||
/** | ||
* Background Cloud Function that returns a Promise. | ||
* | ||
* @param {Object} data Request data, provided by a trigger. | ||
* @returns {Promise} | ||
*/ | ||
exports.helloPromise = function helloPromise (data) { | ||
return request({ | ||
uri: data.endpoint | ||
}); | ||
}; | ||
// [END helloPromise] |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "nodejs-docs-samples-functions", | ||
"description": "Node.js samples found on https://cloud.google.com", | ||
"version": "0.0.1", | ||
"private": true, | ||
"license": "Apache Version 2.0", | ||
"author": "Google Inc.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" | ||
}, | ||
"dependencies": { | ||
"request-promise": "^3.0.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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.
What's a background function?
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.
Any function that's triggered, without the "triggerer" waiting for a response. This will be thoroughly documented in the docs.