From e42d222f8048e20ace7dfe2503b398371a716b9a Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Fri, 30 Mar 2018 01:40:07 -0700 Subject: [PATCH 1/6] Merge samples for Flex and Std --- appengine/README.md | 31 +++++- appengine/analytics/README.md | 24 +++-- .../analytics/{app.yaml => app.flexible.yaml} | 0 appengine/analytics/app.standard.yaml | 21 ++++ appengine/analytics/package.json | 8 +- appengine/building-an-app/build/README.md | 38 ++++++++ appengine/building-an-app/build/app.yaml | 16 ++++ appengine/building-an-app/build/package.json | 29 ++++++ appengine/building-an-app/build/server.js | 33 +++++++ .../building-an-app/build/test/server.test.js | 36 +++++++ appengine/building-an-app/update/README.md | 38 ++++++++ appengine/building-an-app/update/app.yaml | 16 ++++ appengine/building-an-app/update/package.json | 31 ++++++ appengine/building-an-app/update/server.js | 56 +++++++++++ .../update/test/server.test.js | 59 ++++++++++++ .../building-an-app/update/views/form.html | 20 ++++ appengine/cloudsql/README.md | 12 ++- .../cloudsql/{app.yaml => app.flexible.yaml} | 0 appengine/cloudsql/app.standard.yaml | 33 +++++++ appengine/cloudsql/package.json | 8 +- appengine/cloudsql_postgresql/README.md | 16 ++-- .../{app.yaml => app.flexible.yaml} | 0 .../cloudsql_postgresql/app.standard.yaml | 33 +++++++ appengine/cloudsql_postgresql/package.json | 8 +- appengine/cloudtasks/README.md | 30 +++++- .../{app.yaml => app.flexible.yaml} | 0 appengine/cloudtasks/app.standard.yaml | 16 ++++ appengine/cloudtasks/package.json | 8 +- appengine/datastore/README.md | 23 ++--- .../datastore/{app.yaml => app.flexible.yaml} | 0 appengine/datastore/app.standard.yaml | 16 ++++ appengine/datastore/package.json | 8 +- appengine/errorreporting/README.md | 4 +- .../{app.yaml => app.flexible.yaml} | 0 appengine/errorreporting/app.standard.yaml | 16 ++++ appengine/errorreporting/package.json | 8 +- .../hello-world/{ => flexible}/README.md | 2 +- appengine/hello-world/{ => flexible}/app.js | 0 appengine/hello-world/{ => flexible}/app.yaml | 0 .../hello-world/{ => flexible}/package.json | 0 appengine/hello-world/standard/README.md | 56 +++++++++++ appengine/hello-world/standard/app.js | 33 +++++++ appengine/hello-world/standard/app.yaml | 16 ++++ appengine/hello-world/standard/package.json | 39 ++++++++ appengine/loopback/README.md | 8 +- .../loopback/{app.yaml => app.flexible.yaml} | 0 appengine/loopback/app.standard.yaml | 16 ++++ appengine/loopback/package.json | 2 +- appengine/mailjet/README.md | 3 +- .../mailjet/{app.yaml => app.flexible.yaml} | 0 appengine/mailjet/app.js | 6 +- appengine/mailjet/app.standard.yaml | 20 ++++ appengine/mailjet/package.json | 8 +- appengine/memcached/README.md | 3 +- .../memcached/{app.yaml => app.flexible.yaml} | 0 appengine/memcached/app.standard.yaml | 30 ++++++ appengine/memcached/package.json | 4 +- appengine/metadata/flexible/app.yaml | 17 ++++ .../metadata/{ => flexible}/package.json | 7 +- appengine/metadata/{ => flexible}/server.js | 0 appengine/metadata/standard/app.yaml | 16 ++++ appengine/metadata/standard/package.json | 40 ++++++++ appengine/metadata/standard/server.js | 60 ++++++++++++ appengine/mongodb/README.md | 10 +- .../mongodb/{app.yaml => app.flexible.yaml} | 0 appengine/mongodb/app.standard.yaml | 16 ++++ appengine/mongodb/package.json | 2 +- appengine/parse-server/README.md | 14 ++- .../{app.yaml => app.flexible.yaml} | 0 appengine/parse-server/app.standard.yaml | 16 ++++ appengine/parse-server/package.json | 2 +- appengine/pubsub/README.md | 3 +- .../pubsub/{app.yaml => app.flexible.yaml} | 0 appengine/pubsub/app.standard.yaml | 28 ++++++ appengine/pubsub/package.json | 2 +- appengine/redis/README.md | 8 +- .../redis/{app.yaml => app.flexible.yaml} | 0 appengine/redis/app.standard.yaml | 16 ++++ appengine/redis/package.json | 2 +- appengine/sendgrid/README.md | 13 ++- .../sendgrid/{app.yaml => app.flexible.yaml} | 0 appengine/sendgrid/app.standard.yaml | 22 +++++ appengine/sendgrid/package.json | 2 +- appengine/static-files/README.md | 2 +- .../{app.yaml => app.flexible.yaml} | 0 appengine/static-files/app.standard.yaml | 16 ++++ appengine/static-files/package.json | 2 +- appengine/storage/{ => flexible}/README.md | 2 +- appengine/storage/{ => flexible}/app.js | 0 appengine/storage/{ => flexible}/app.yaml | 0 appengine/storage/{ => flexible}/package.json | 0 .../{ => flexible}/system-test/app.test.js | 0 .../system-test/resources/test.txt | 0 .../storage/{ => flexible}/views/form.pug | 0 appengine/storage/standard/README.md | 40 ++++++++ appengine/storage/standard/app.js | 96 +++++++++++++++++++ appengine/storage/standard/app.yaml | 21 ++++ appengine/storage/standard/package.json | 40 ++++++++ .../storage/standard/system-test/app.test.js | 62 ++++++++++++ .../standard/system-test/resources/test.txt | 1 + appengine/storage/standard/views/form.pug | 10 ++ appengine/system-test/all.test.js | 11 ++- appengine/twilio/README.md | 5 +- .../twilio/{app.yaml => app.flexible.yaml} | 0 appengine/twilio/app.standard.yaml | 23 +++++ appengine/twilio/package.json | 4 +- 106 files changed, 1452 insertions(+), 120 deletions(-) rename appengine/analytics/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/analytics/app.standard.yaml create mode 100644 appengine/building-an-app/build/README.md create mode 100755 appengine/building-an-app/build/app.yaml create mode 100755 appengine/building-an-app/build/package.json create mode 100755 appengine/building-an-app/build/server.js create mode 100755 appengine/building-an-app/build/test/server.test.js create mode 100644 appengine/building-an-app/update/README.md create mode 100755 appengine/building-an-app/update/app.yaml create mode 100755 appengine/building-an-app/update/package.json create mode 100755 appengine/building-an-app/update/server.js create mode 100755 appengine/building-an-app/update/test/server.test.js create mode 100755 appengine/building-an-app/update/views/form.html rename appengine/cloudsql/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/cloudsql/app.standard.yaml rename appengine/cloudsql_postgresql/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/cloudsql_postgresql/app.standard.yaml rename appengine/cloudtasks/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/cloudtasks/app.standard.yaml rename appengine/datastore/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/datastore/app.standard.yaml rename appengine/errorreporting/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/errorreporting/app.standard.yaml rename appengine/hello-world/{ => flexible}/README.md (97%) rename appengine/hello-world/{ => flexible}/app.js (100%) rename appengine/hello-world/{ => flexible}/app.yaml (100%) rename appengine/hello-world/{ => flexible}/package.json (100%) create mode 100644 appengine/hello-world/standard/README.md create mode 100644 appengine/hello-world/standard/app.js create mode 100644 appengine/hello-world/standard/app.yaml create mode 100644 appengine/hello-world/standard/package.json rename appengine/loopback/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/loopback/app.standard.yaml rename appengine/mailjet/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/mailjet/app.standard.yaml rename appengine/memcached/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/memcached/app.standard.yaml create mode 100644 appengine/metadata/flexible/app.yaml rename appengine/metadata/{ => flexible}/package.json (88%) rename appengine/metadata/{ => flexible}/server.js (100%) create mode 100644 appengine/metadata/standard/app.yaml create mode 100644 appengine/metadata/standard/package.json create mode 100644 appengine/metadata/standard/server.js rename appengine/mongodb/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/mongodb/app.standard.yaml rename appengine/parse-server/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/parse-server/app.standard.yaml rename appengine/pubsub/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/pubsub/app.standard.yaml rename appengine/redis/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/redis/app.standard.yaml rename appengine/sendgrid/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/sendgrid/app.standard.yaml rename appengine/static-files/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/static-files/app.standard.yaml rename appengine/storage/{ => flexible}/README.md (94%) rename appengine/storage/{ => flexible}/app.js (100%) rename appengine/storage/{ => flexible}/app.yaml (100%) rename appengine/storage/{ => flexible}/package.json (100%) rename appengine/storage/{ => flexible}/system-test/app.test.js (100%) rename appengine/storage/{ => flexible}/system-test/resources/test.txt (100%) rename appengine/storage/{ => flexible}/views/form.pug (100%) create mode 100644 appengine/storage/standard/README.md create mode 100644 appengine/storage/standard/app.js create mode 100644 appengine/storage/standard/app.yaml create mode 100644 appengine/storage/standard/package.json create mode 100644 appengine/storage/standard/system-test/app.test.js create mode 100644 appengine/storage/standard/system-test/resources/test.txt create mode 100644 appengine/storage/standard/views/form.pug rename appengine/twilio/{app.yaml => app.flexible.yaml} (100%) create mode 100644 appengine/twilio/app.standard.yaml diff --git a/appengine/README.md b/appengine/README.md index c634bc093a..379875f429 100644 --- a/appengine/README.md +++ b/appengine/README.md @@ -1,7 +1,7 @@ # Google App Engine Node.js Samples These are samples for using [Node.js][nodejs] on -[Google App Engine Flexible Environment][appengine]. Many of these samples +[Google App Engine][appengine]. Many of these samples are referenced from the documentation on [cloud.google.com][appengine]. There are also samples [submitted by the community][community_samples]. @@ -57,17 +57,42 @@ The App Engine Node.js samples typically that you do the following: ## Deploying -Some samples in this repositories may have special deployment instructions. +Some samples may have special deployment instructions. Refer to the `README.md` file in the sample folder. +Many samples in this folder can be deployed to both App Engine Node.js Standard +Environment and Flexible Environment. Those samples come with two different +App Engine configuration files: `app.flexible.yaml` for Flexible Environment, +and `app.standard.yaml` for Standard Environment. + +Samples with one single configuration file, `app.yaml`, can only be deployed +to one of the two environments. See the `README.md` files for these samples +for more information. + +Generally speaking, to deploy a sample application: + 1. Use the [Google Cloud Console][console] to create a Google Cloud Platform project. 1. [Enable billing][billing] for your project. 1. Use the Cloud SDK to deploy your app. + For samples with two configuration files (`app.flexible.yaml` and + `app.standard.yaml`), if you plan to use App Engine Node.js Standard + Environment, run + + gcloud app deploy app.standard.yaml + + To deploy to App Engine Node.js Flexible Environment, run + + gcloud app deploy app.flexible.yaml + + For samples with one configuration file (`app.yaml`), run + gcloud app deploy + to deploy the app to its compatible environment. + Note: If there is a `yarn.lock` file then `yarn install` will be used during deployment. Delete the `yarn.lock` file to fall back to `npm install`. @@ -82,7 +107,7 @@ View the [Official App Engine Node.js samples][official_samples]. View the [Community-contributed App Engine Node.js samples][community_samples]. [nodejs]: https://nodejs.org/ -[appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs/ +[appengine]: https://cloud.google.com/appengine/ [nodejs_dev]: https://cloud.google.com/community/tutorials/how-to-prepare-a-nodejs-dev-environment [sdk]: https://cloud.google.com/sdk/ [console]: https://console.cloud.google.com diff --git a/appengine/analytics/README.md b/appengine/analytics/README.md index 4771f93654..dcf9273264 100644 --- a/appengine/analytics/README.md +++ b/appengine/analytics/README.md @@ -1,8 +1,11 @@ # Integrating with Google Analytics -This is the sample application for the -[Integrating with Google Analytics tutorial][tutorial] tutorial found in the -[Google App Engine Node.js Flexible Environment][appengine] documentation. +This sample application shows how to integrate your Node.js application with +Google Analytics on Google App Engine. + +App Engine Node.js Standard Environment users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app. + +App Engine Node.js Flexible Environment users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -37,22 +40,23 @@ or with `yarn`: GA_TRACKING_ID=YOUR_TRACKING_ID yarn start -## Deploying to App Engine +## Deploying to App Engine Standard Environment -With `npm`: + gcloud app deploy app.standard.yaml - npm run deploy +## Deploying to App Engine Flexible Environment -or with `yarn`: + gcloud app deploy app.flexible.yaml - yarn run deploy ## Running the tests See [Contributing][contributing]. -[appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs -[tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/integrating-with-analytics +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs +[flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/integrating-with-analytics +[std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/integrating-with-analytics [readme]: ../README.md [tracking]: https://support.google.com/analytics/answer/1042508 [contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/analytics/app.yaml b/appengine/analytics/app.flexible.yaml similarity index 100% rename from appengine/analytics/app.yaml rename to appengine/analytics/app.flexible.yaml diff --git a/appengine/analytics/app.standard.yaml b/appengine/analytics/app.standard.yaml new file mode 100644 index 0000000000..5746c3569b --- /dev/null +++ b/appengine/analytics/app.standard.yaml @@ -0,0 +1,21 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env] +env_variables: + GA_TRACKING_ID: YOUR_TRACKING_ID +# [END env] +# [END app_yaml] diff --git a/appengine/analytics/package.json b/appengine/analytics/package.json index 5f4e96dd39..dd1015b4c6 100644 --- a/appengine/analytics/package.json +++ b/appengine/analytics/package.json @@ -1,6 +1,6 @@ { "name": "appengine-analytics", - "description": "Sample for Google Analytics Measurement Protocol on Google App Engine Flexible Environment.", + "description": "Sample for Google Analytics Measurement Protocol on Google App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,16 +10,14 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "start": "node app.js", "lint": "repo-tools lint", "pretest": "npm run lint", "system-test": "repo-tools test app", - "test": "npm run system-test", - "e2e-test": "repo-tools test deploy" + "test": "npm run system-test" }, "dependencies": { "express": "4.16.0", diff --git a/appengine/building-an-app/build/README.md b/appengine/building-an-app/build/README.md new file mode 100644 index 0000000000..9bbcd1abcb --- /dev/null +++ b/appengine/building-an-app/build/README.md @@ -0,0 +1,38 @@ +# Writing Your Web Service Sample for Node.js in the App Engine Standard Environment + +This is the sample application for the +[Writing Your Web Service with Node.js][tutorial] +tutorial found in the [Google App Engine Node.js Standard Environment][appengine] +documentation. + +* [Setup](#setup) +* [Running locally](#running-locally) +* [Deploying to App Engine](#deploying-to-app-engine) +* [Running the tests](#running-the-tests) + +## Setup + +Before you can run or deploy the sample, you need to do the following: + +1. Refer to the [appengine/README.md][readme] file for instructions on + running and deploying. +1. Install dependencies: + + npm install + +## Running locally + + npm start + +## Deploying to App Engine + + npm run deploy + +## Running the tests + +See [Contributing][contributing]. + +[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs +[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/writing-web-service +[readme]: ../../README.md +[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/building-an-app/build/app.yaml b/appengine/building-an-app/build/app.yaml new file mode 100755 index 0000000000..e938832ccb --- /dev/null +++ b/appengine/building-an-app/build/app.yaml @@ -0,0 +1,16 @@ +# Copyright 2018, 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/building-an-app/build/package.json b/appengine/building-an-app/build/package.json new file mode 100755 index 0000000000..415dcd3014 --- /dev/null +++ b/appengine/building-an-app/build/package.json @@ -0,0 +1,29 @@ +{ + "name": "appengine-standard-getting-started-build-apps", + "version": "0.0.1", + "description": "Node.js getting started sample for building an app on App Engine standard environment.", + "private": true, + "main": "server.js", + "scripts": { + "lint": "samples lint", + "pretest": "npm run lint", + "test": "ava --verbose test/*.test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": "8.x.x" + }, + "author": "Google Inc.", + "license": "Apache-2.0", + "dependencies": { + "express": "^4.16.3" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.4.17", + "ava": "0.22.0", + "semistandard": "^12.0.1" + } +} diff --git a/appengine/building-an-app/build/server.js b/appengine/building-an-app/build/server.js new file mode 100755 index 0000000000..a9918495c2 --- /dev/null +++ b/appengine/building-an-app/build/server.js @@ -0,0 +1,33 @@ +/** + * Copyright 2018, 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 app] +const express = require('express'); +const app = express(); + +app.get('/', (req, res) => { + res.send('Hello from App Engine!'); +}); + +// Listen to the App Engine-specified port, or 8080 otherwise +const PORT = process.env.PORT || 8080; +app.listen(PORT, () => { + console.log(`Server listening on port ${PORT}...`); +}); +// [END app] + +module.exports = app; diff --git a/appengine/building-an-app/build/test/server.test.js b/appengine/building-an-app/build/test/server.test.js new file mode 100755 index 0000000000..45323f68fe --- /dev/null +++ b/appengine/building-an-app/build/test/server.test.js @@ -0,0 +1,36 @@ +// Copyright 2018, 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'; + +const path = require(`path`); +const test = require(`ava`); +const utils = require(`@google-cloud/nodejs-repo-tools`); + +const cwd = path.join(__dirname, `../`); +const requestObj = utils.getRequest({ + cwd: cwd, + cmd: `server` }); + +test.beforeEach(utils.stubConsole); +test.afterEach.always(utils.restoreConsole); + +test.cb.serial(`should send greetings`, (t) => { + requestObj + .get(`/`) + .expect(200) + .expect((response) => { + t.is(response.text, `Hello from App Engine!`); + }) + .end(t.end); +}); diff --git a/appengine/building-an-app/update/README.md b/appengine/building-an-app/update/README.md new file mode 100644 index 0000000000..e3cd57ceb8 --- /dev/null +++ b/appengine/building-an-app/update/README.md @@ -0,0 +1,38 @@ +# Updating Your Web Service Sample for Node.js in the App Engine Standard Environment + +This is the sample application for the +[Updating Your Web Service][tutorial] +tutorial found in the [Google App Engine Node.js Standard Environment][appengine] +documentation. + +* [Setup](#setup) +* [Running locally](#running-locally) +* [Deploying to App Engine](#deploying-to-app-engine) +* [Running the tests](#running-the-tests) + +## Setup + +Before you can run or deploy the sample, you need to do the following: + +1. Refer to the [appengine/README.md][readme] file for instructions on + running and deploying. +1. Install dependencies: + + npm install + +## Running locally + + npm start + +## Deploying to App Engine + + npm run deploy + +## Running the tests + +See [Contributing][contributing]. + +[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs +[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/updating-web-service +[readme]: ../../README.md +[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/building-an-app/update/app.yaml b/appengine/building-an-app/update/app.yaml new file mode 100755 index 0000000000..e938832ccb --- /dev/null +++ b/appengine/building-an-app/update/app.yaml @@ -0,0 +1,16 @@ +# Copyright 2018, 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/building-an-app/update/package.json b/appengine/building-an-app/update/package.json new file mode 100755 index 0000000000..d0117269a1 --- /dev/null +++ b/appengine/building-an-app/update/package.json @@ -0,0 +1,31 @@ +{ + "name": "appengine-standard-getting-started-update-apps", + "version": "0.0.1", + "description": "Node.js getting started sample for updating an app on App Engine standard environment.", + "private": true, + "main": "server.js", + "scripts": { + "lint": "samples lint", + "pretest": "npm run lint", + "test": "ava --verbose test/*.test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": "8.x.x" + }, + "author": "Google Inc.", + "license": "Apache-2.0", + "dependencies": { + "body-parser": "^1.18.2", + "express": "^4.16.3", + "semistandard": "^12.0.1" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.4.17", + "ava": "0.22.0", + "semistandard": "^12.0.1" + } +} diff --git a/appengine/building-an-app/update/server.js b/appengine/building-an-app/update/server.js new file mode 100755 index 0000000000..de0afd5a33 --- /dev/null +++ b/appengine/building-an-app/update/server.js @@ -0,0 +1,56 @@ +/** + * Copyright 2018, 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 app] +const express = require('express'); +const bodyParser = require('body-parser'); +const path = require(`path`); + +const app = express(); + +// [START enable_parser] +app.use(bodyParser.urlencoded({ extended: true })); +// [END enable_parser] + +app.get('/', (req, res) => { + res.send('Hello from App Engine!'); +}); + +// [START add_display_form] +app.get('/submit', (req, res) => { + res.sendFile(path.join(__dirname, '/views/form.html')); +}); +// [END add_display_form] + +// [START add_post_handler] +app.post('/submit', (req, res) => { + console.log({ + name: req.body.name, + message: req.body.message + }); + res.send('Thanks for your message!'); +}); +// [END add_post_handler] + +// Listen to the App Engine-specified port, or 8080 otherwise +const PORT = process.env.PORT || 8080; +app.listen(PORT, () => { + console.log(`Server listening on port ${PORT}...`); +}); +// [END app] + +module.exports = app; diff --git a/appengine/building-an-app/update/test/server.test.js b/appengine/building-an-app/update/test/server.test.js new file mode 100755 index 0000000000..c35766abd0 --- /dev/null +++ b/appengine/building-an-app/update/test/server.test.js @@ -0,0 +1,59 @@ +// Copyright 2018, 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'; + +const path = require(`path`); +const test = require(`ava`); +const utils = require(`@google-cloud/nodejs-repo-tools`); + +const cwd = path.join(__dirname, `../`); +const requestObj = utils.getRequest({ + cwd: cwd, + cmd: `server` }); + +test.beforeEach(utils.stubConsole); +test.afterEach.always(utils.restoreConsole); + +test.cb.serial(`should send greetings`, (t) => { + requestObj + .get(`/`) + .expect(200) + .expect((response) => { + t.is(response.text, `Hello from App Engine!`); + }) + .end(t.end); +}); + +test.cb.serial(`should display form`, (t) => { + requestObj + .get(`/submit`) + .expect(200) + .expect((response) => { + t.regex(response.text, /textarea name="message" placeholder="Message"/); + }) + .end(t.end); +}); + +test.cb.serial(`should record message`, (t) => { + requestObj + .post(`/submit`, { + name: `sample-user`, + message: `sample-message` + }) + .expect(200) + .expect((response) => { + t.is(response.text, `Thanks for your message!`); + }) + .end(t.end); +}); diff --git a/appengine/building-an-app/update/views/form.html b/appengine/building-an-app/update/views/form.html new file mode 100755 index 0000000000..ad738456a3 --- /dev/null +++ b/appengine/building-an-app/update/views/form.html @@ -0,0 +1,20 @@ + + + + My App Engine App + + +

Create a new post

+
+
+ +
+
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/appengine/cloudsql/README.md b/appengine/cloudsql/README.md index 3c5c14ed4b..2e615a23f0 100644 --- a/appengine/cloudsql/README.md +++ b/appengine/cloudsql/README.md @@ -1,11 +1,13 @@ # Cloud SQL for MySQL Node.js sample on App Engine flexible environment -This sample demonstrates how to use [Google Cloud SQL][sql] for -[MySQL][mysql] on [Google App Engine Flexible][flexible]. +This sample application shows how to use [Google Cloud SQL[[sql] for [MySQL][mysql] +on Google App Engine. -To run the sample, see [the tutorial][tutorial]. +App Engine Standard users: See tutorial [Using Cloud SQL for MySQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. + +App Engine Flexible users: See tutorial [Using Cloud SQL for MySQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ -[flexible]: https://cloud.google.com/appengine [mysql]: https://www.mysql.com/downloads/ -[tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql +[flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql +[std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-sql diff --git a/appengine/cloudsql/app.yaml b/appengine/cloudsql/app.flexible.yaml similarity index 100% rename from appengine/cloudsql/app.yaml rename to appengine/cloudsql/app.flexible.yaml diff --git a/appengine/cloudsql/app.standard.yaml b/appengine/cloudsql/app.standard.yaml new file mode 100644 index 0000000000..c96f7f553b --- /dev/null +++ b/appengine/cloudsql/app.standard.yaml @@ -0,0 +1,33 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env] +env_variables: + SQL_USER: YOUR_SQL_USER + SQL_PASSWORD: YOUR_SQL_PASSWORD + SQL_DATABASE: YOUR_SQL_DATABASE + # e.g. my-awesome-project:us-central1:my-cloud-sql-instance + INSTANCE_CONNECTION_NAME: YOUR_INSTANCE_CONNECTION_NAME +# [END env] + +# [START cloudsql_settings] +beta_settings: + # The connection name of your instance, available by using + # 'gcloud beta sql instances describe [INSTANCE_NAME]' or from + # the Instance details page in the Google Cloud Platform Console. + cloud_sql_instances: YOUR_INSTANCE_CONNECTION_NAME +# [END cloudsql_settings] +# [END app_yaml] diff --git a/appengine/cloudsql/package.json b/appengine/cloudsql/package.json index 4ec82752e3..3d5ea04272 100644 --- a/appengine/cloudsql/package.json +++ b/appengine/cloudsql/package.json @@ -1,6 +1,6 @@ { "name": "appengine-cloudsql-mysql", - "description": "Node.js MySQL sample for Cloud SQL on App Engine flexible environment.", + "description": "Node.js MySQL sample for Cloud SQL on App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,10 +10,9 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "lint": "samples lint", "pretest": "npm run lint", "unit-test": "ava --verbose test/*.test.js", @@ -21,8 +20,7 @@ "system-test": "samples test app", "system-test-proxy": "npm run start-proxy; npm run system-test", "all-test": "npm run unit-test && npm run system-test", - "test": "samples test run --cmd npm -- run all-test", - "e2e-test": "samples test deploy" + "test": "samples test run --cmd npm -- run all-test" }, "dependencies": { "async": "2.5.0", diff --git a/appengine/cloudsql_postgresql/README.md b/appengine/cloudsql_postgresql/README.md index e1981e39fa..fafc2eb5d0 100644 --- a/appengine/cloudsql_postgresql/README.md +++ b/appengine/cloudsql_postgresql/README.md @@ -1,11 +1,15 @@ -# Cloud SQL for Postgres Node.js sample on App Engine flexible environment +# Cloud SQL for MySQL Node.js sample on App Engine flexible environment -This sample demonstrates how to use [Google Cloud SQL][sql] for -[Postgres][postgres] on [Google App Engine Flexible][flexible]. +This sample application shows how to use [Google Cloud SQL[[sql] for [PostgreSQL][postgres] +on Google App Engine. -To run the sample, see [the tutorial][tutorial]. +App Engine Standard users: See tutorial [ +Using Cloud SQL for PostgreSQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. + +App Engine Flexible users: See tutorial [ +Using Cloud SQL for PostgreSQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ -[flexible]: https://cloud.google.com/appengine [postgres]: https://www.postgresql.org/download/ -[tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql-postgres +[flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql-postgres +[std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-sql-postgres diff --git a/appengine/cloudsql_postgresql/app.yaml b/appengine/cloudsql_postgresql/app.flexible.yaml similarity index 100% rename from appengine/cloudsql_postgresql/app.yaml rename to appengine/cloudsql_postgresql/app.flexible.yaml diff --git a/appengine/cloudsql_postgresql/app.standard.yaml b/appengine/cloudsql_postgresql/app.standard.yaml new file mode 100644 index 0000000000..c96f7f553b --- /dev/null +++ b/appengine/cloudsql_postgresql/app.standard.yaml @@ -0,0 +1,33 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env] +env_variables: + SQL_USER: YOUR_SQL_USER + SQL_PASSWORD: YOUR_SQL_PASSWORD + SQL_DATABASE: YOUR_SQL_DATABASE + # e.g. my-awesome-project:us-central1:my-cloud-sql-instance + INSTANCE_CONNECTION_NAME: YOUR_INSTANCE_CONNECTION_NAME +# [END env] + +# [START cloudsql_settings] +beta_settings: + # The connection name of your instance, available by using + # 'gcloud beta sql instances describe [INSTANCE_NAME]' or from + # the Instance details page in the Google Cloud Platform Console. + cloud_sql_instances: YOUR_INSTANCE_CONNECTION_NAME +# [END cloudsql_settings] +# [END app_yaml] diff --git a/appengine/cloudsql_postgresql/package.json b/appengine/cloudsql_postgresql/package.json index 296ee7fbf2..220055c238 100644 --- a/appengine/cloudsql_postgresql/package.json +++ b/appengine/cloudsql_postgresql/package.json @@ -1,6 +1,6 @@ { "name": "appengine-cloudsql-postgres", - "description": "Node.js PostgreSQL sample for Cloud SQL on App Engine flexible environment.", + "description": "Node.js PostgreSQL sample for Cloud SQL on App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,10 +10,9 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "lint": "samples lint", "pretest": "npm run lint", "unit-test": "ava --verbose test/*.test.js", @@ -21,8 +20,7 @@ "system-test": "samples test app", "system-test-proxy": "npm run start-proxy; npm run system-test", "all-test": "npm run unit-test && npm run system-test", - "test": "samples test run --cmd npm -- run all-test", - "e2e-test": "samples test deploy" + "test": "samples test run --cmd npm -- run all-test" }, "dependencies": { "async": "2.5.0", diff --git a/appengine/cloudtasks/README.md b/appengine/cloudtasks/README.md index ab2db06d66..7d7133950c 100644 --- a/appengine/cloudtasks/README.md +++ b/appengine/cloudtasks/README.md @@ -1,7 +1,7 @@ # Node.js Google Cloud Tasks sample for Google App Engine -This sample demonstrates how to use [Google Cloud Tasks](https://cloud.google.com/cloud-tasks/) -on [Google App Engine Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). +This sample application shows how to use [Google Cloud Tasks](https://cloud.google.com/cloud-tasks/) +on Google App Engine Node.js Standard Environment and Flexible Environment. App Engine queues push tasks to an App Engine HTTP target. This directory contains both the App Engine app to deploy, as well as the snippets to run @@ -13,7 +13,11 @@ the App Engine app. `server.js` is the main App Engine app. This app serves as an endpoint to receive App Engine task attempts. -`app.yaml` configures the App Engine app. +`app.standard.yaml` configures the app for App Engine Node.js Standard +Environment. + +`app.flexible.yaml` configures the app for App Engine Node.js Flexible +Environment. * [Setup](#setup) * [Running locally](#running-locally) @@ -48,11 +52,27 @@ version unless configured to do otherwise. Read the online help for the `create-app-engine-queue` or the `update-app-engine-queue` commands to learn about routing overrides for App Engine queues. -## Deploying the App Engine app +## Deploying the app to App Engine Standard Environment + +Deploy the App Engine app with gcloud: + + gcloud app deploy app.standard.yaml + +Verify the index page is serving: + + gcloud app browse + +The App Engine app serves as a target for the push requests. It has an +endpoint `/log_payload` that reads the payload (i.e., the request body) of the +HTTP POST request and logs it. The log output can be viewed with: + + gcloud app logs read + +## Deploying the app to App Engine Flexible Environment Deploy the App Engine app with gcloud: - gcloud app deploy + gcloud app deploy app.flexible.yaml Verify the index page is serving: diff --git a/appengine/cloudtasks/app.yaml b/appengine/cloudtasks/app.flexible.yaml similarity index 100% rename from appengine/cloudtasks/app.yaml rename to appengine/cloudtasks/app.flexible.yaml diff --git a/appengine/cloudtasks/app.standard.yaml b/appengine/cloudtasks/app.standard.yaml new file mode 100644 index 0000000000..8f8f6fd97a --- /dev/null +++ b/appengine/cloudtasks/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/cloudtasks/package.json b/appengine/cloudtasks/package.json index 8eb6adfa4d..a0414b9ce0 100644 --- a/appengine/cloudtasks/package.json +++ b/appengine/cloudtasks/package.json @@ -1,23 +1,21 @@ { "name": "appengine-cloudtasks", - "description": "Google App Engine Flexible Environment Cloud Tasks example.", + "description": "Google App Engine Standard Environment Cloud Tasks example.", "version": "0.0.0", "license": "Apache-2.0", "author": "Google Inc.", "private": true, "repository": "GoogleCloudPlatform/nodejs-docs-samples", "engines": { - "node": ">=4.0.0" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "lint": "repo-tools lint", "pretest": "npm run lint", "unit-test": "ava --verbose test/*.test.js", "system-test": "repo-tools test app --config package.json --config-key cloud-repo-tools", "all-test": "npm run unit-test && npm run system-test", - "test": "repo-tools test run --cmd npm -- run all-test", - "e2e-test": "repo-tools test deploy --config package.json --config-key cloud-repo-tools" + "test": "repo-tools test run --cmd npm -- run all-test" }, "dependencies": { "body-parser": "1.18.2", diff --git a/appengine/datastore/README.md b/appengine/datastore/README.md index 0efae30781..05459e0dda 100644 --- a/appengine/datastore/README.md +++ b/appengine/datastore/README.md @@ -1,8 +1,11 @@ # Using Cloud Datastore -This is the sample application for the -[Using Cloud Datastore][tutorial] tutorial found in the -[Google App Engine Node.js Flexible Environment][appengine] documentation. +This sample application shows how to use Google Cloud Datastore on Google App +Engine. + +App Engine Node.js Standard Environment users: See tutorial [Using Cloud Datastore][tutorial-std] for more information on running and deploying this app. + +App Engine Node.js Flexible Environment users: See tutorial [Using Cloud Datastore][tutorial-flex] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -35,21 +38,19 @@ or with `yarn`: yarn start -## Deploying to App Engine +## Deploying to App Engine Standard Environment -With `npm`: + gcloud app deploy app.standard.yaml - npm run deploy - -or with `yarn`: +## Deploying to App Engine Flexible Environment - yarn run deploy + gcloud app deploy app.flexible.yaml ## Running the tests See [Contributing][contributing]. -[appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs -[tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-datastore +[tutorial-std]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-datastore +[tutorial-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-datastore [readme]: ../README.md [contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/datastore/app.yaml b/appengine/datastore/app.flexible.yaml similarity index 100% rename from appengine/datastore/app.yaml rename to appengine/datastore/app.flexible.yaml diff --git a/appengine/datastore/app.standard.yaml b/appengine/datastore/app.standard.yaml new file mode 100644 index 0000000000..8f8f6fd97a --- /dev/null +++ b/appengine/datastore/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/datastore/package.json b/appengine/datastore/package.json index dc0718997f..8a5e574d85 100644 --- a/appengine/datastore/package.json +++ b/appengine/datastore/package.json @@ -1,6 +1,6 @@ { "name": "appengine-datastore", - "description": "Sample for Google Cloud Datastore on Google App Engine Flexible Environment.", + "description": "Sample for Google Cloud Datastore on Google App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,16 +10,14 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "start": "node app.js", "lint": "samples lint", "pretest": "npm run lint", "system-test": "samples test app", - "test": "npm run system-test", - "e2e-test": "samples test deploy" + "test": "npm run system-test" }, "dependencies": { "@google-cloud/datastore": "1.1.0", diff --git a/appengine/errorreporting/README.md b/appengine/errorreporting/README.md index f4b8f03a6c..0eb40321e9 100644 --- a/appengine/errorreporting/README.md +++ b/appengine/errorreporting/README.md @@ -1,7 +1,7 @@ # Node.js error reporting sample for Google App Engine -This sample demonstrates error reporting in a Node.js app for -[Google App Engine Flexible Environment](https://cloud.google.com/appengine). +This sample shows how to use Stackdriver Error Reporting on Google App Engine +Node.js Standard Environment and Flexible Environment. ## Running locally diff --git a/appengine/errorreporting/app.yaml b/appengine/errorreporting/app.flexible.yaml similarity index 100% rename from appengine/errorreporting/app.yaml rename to appengine/errorreporting/app.flexible.yaml diff --git a/appengine/errorreporting/app.standard.yaml b/appengine/errorreporting/app.standard.yaml new file mode 100644 index 0000000000..8cf0f07dc8 --- /dev/null +++ b/appengine/errorreporting/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/errorreporting/package.json b/appengine/errorreporting/package.json index 84d06864b6..2e08ba5421 100644 --- a/appengine/errorreporting/package.json +++ b/appengine/errorreporting/package.json @@ -1,6 +1,6 @@ { "name": "appengine-error-reporting", - "description": "Node.js error reporting sample for Google App Engine Flexible Environment.", + "description": "Node.js error reporting sample for Google App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,17 +10,15 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "start": "node app.js", "lint": "samples lint", "pretest": "npm run lint", "unit-test": "ava --verbose test/*.test.js", "system-test": "samples test app", - "test": "npm run unit-test && npm run system-test", - "e2e-test": "samples test deploy" + "test": "npm run unit-test && npm run system-test" }, "dependencies": { "@google-cloud/error-reporting": "0.2.1", diff --git a/appengine/hello-world/README.md b/appengine/hello-world/flexible/README.md similarity index 97% rename from appengine/hello-world/README.md rename to appengine/hello-world/flexible/README.md index eff3ee5949..246ed92a5a 100644 --- a/appengine/hello-world/README.md +++ b/appengine/hello-world/flexible/README.md @@ -52,5 +52,5 @@ See [Contributing][contributing]. [appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs [tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/quickstart -[readme]: ../README.md +[readme]: ../../README.md [contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/hello-world/app.js b/appengine/hello-world/flexible/app.js similarity index 100% rename from appengine/hello-world/app.js rename to appengine/hello-world/flexible/app.js diff --git a/appengine/hello-world/app.yaml b/appengine/hello-world/flexible/app.yaml similarity index 100% rename from appengine/hello-world/app.yaml rename to appengine/hello-world/flexible/app.yaml diff --git a/appengine/hello-world/package.json b/appengine/hello-world/flexible/package.json similarity index 100% rename from appengine/hello-world/package.json rename to appengine/hello-world/flexible/package.json diff --git a/appengine/hello-world/standard/README.md b/appengine/hello-world/standard/README.md new file mode 100644 index 0000000000..afc2f09bf0 --- /dev/null +++ b/appengine/hello-world/standard/README.md @@ -0,0 +1,56 @@ +# Quickstart for Node.js in the App Engine Standard Environment + +This is the sample application for the +[Quickstart for Node.js in the App Engine Standard Environment][tutorial] +tutorial found in the [Google App Engine Node.js Flexible Environment][appengine] +documentation. + +* [Setup](#setup) +* [Running locally](#running-locally) +* [Deploying to App Engine](#deploying-to-app-engine) +* [Running the tests](#running-the-tests) + +## Setup + +Before you can run or deploy the sample, you need to do the following: + +1. Refer to the [appengine/README.md][readme] file for instructions on + running and deploying. +1. Install dependencies: + + With `npm`: + + npm install + + or with `yarn`: + + yarn install + +## Running locally + +With `npm`: + + npm start + +or with `yarn`: + + yarn start + +## Deploying to App Engine + +With `npm`: + + npm run deploy + +or with `yarn`: + + yarn run deploy + +## Running the tests + +See [Contributing][contributing]. + +[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs +[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/quickstart +[readme]: ../../README.md +[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md diff --git a/appengine/hello-world/standard/app.js b/appengine/hello-world/standard/app.js new file mode 100644 index 0000000000..be1e3735bc --- /dev/null +++ b/appengine/hello-world/standard/app.js @@ -0,0 +1,33 @@ +/** + * Copyright 2017, 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 app] +const express = require('express'); + +const app = express(); + +app.get('/', (req, res) => { + res.status(200).send('Hello, world!').end(); +}); + +// Start the server +const PORT = process.env.PORT || 8080; +app.listen(PORT, () => { + console.log(`App listening on port ${PORT}`); + console.log('Press Ctrl+C to quit.'); +}); +// [END app] diff --git a/appengine/hello-world/standard/app.yaml b/appengine/hello-world/standard/app.yaml new file mode 100644 index 0000000000..8f8f6fd97a --- /dev/null +++ b/appengine/hello-world/standard/app.yaml @@ -0,0 +1,16 @@ +# Copyright 2017, 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/hello-world/standard/package.json b/appengine/hello-world/standard/package.json new file mode 100644 index 0000000000..97d71af4d3 --- /dev/null +++ b/appengine/hello-world/standard/package.json @@ -0,0 +1,39 @@ +{ + "name": "appengine-hello-world", + "description": "Simple Hello World Node.js sample for Google App Engine Standard Environment.", + "version": "0.0.1", + "private": true, + "license": "Apache-2.0", + "author": "Google Inc.", + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": "8.x.x" + }, + "scripts": { + "deploy": "gcloud app deploy", + "start": "node app.js", + "lint": "samples lint", + "pretest": "npm run lint", + "system-test": "samples test app", + "test": "npm run system-test", + "e2e-test": "samples test deploy" + }, + "dependencies": { + "express": "4.15.4" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.4.17" + }, + "cloud-repo-tools": { + "test": { + "app": { + "msg": "Hello, world!" + } + }, + "requiresKeyFile": true, + "requiresProjectId": true + } +} diff --git a/appengine/loopback/README.md b/appengine/loopback/README.md index e80d7fb9e3..2a11882ab4 100644 --- a/appengine/loopback/README.md +++ b/appengine/loopback/README.md @@ -2,10 +2,14 @@ > [Loopback][1] is a highly-extensible, open-source Node.js framework. -Read the [Loopback.js on App Engine Tutorial][2] for how to run and deploy this +Refer to the [appengine/README.md](../README.md) file for more instructions on +running and deploying this app. + +App Engine Node.js Flexible Environment users may also read the community +tutorial [Loopback.js on App Engine Tutorial][2] for how to run and deploy this sample app. -You can also view the [live demo][3] and read the [Loopback.js documentation][4]. +Additionally, view the [live demo][3] and read the [Loopback.js documentation][4]. [1]: http://loopback.io/ [2]: https://cloud.google.com/nodejs/resources/frameworks/loopback diff --git a/appengine/loopback/app.yaml b/appengine/loopback/app.flexible.yaml similarity index 100% rename from appengine/loopback/app.yaml rename to appengine/loopback/app.flexible.yaml diff --git a/appengine/loopback/app.standard.yaml b/appengine/loopback/app.standard.yaml new file mode 100644 index 0000000000..8cf0f07dc8 --- /dev/null +++ b/appengine/loopback/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/loopback/package.json b/appengine/loopback/package.json index e3a48138ae..5107dfcfc2 100644 --- a/appengine/loopback/package.json +++ b/appengine/loopback/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "main": "server/server.js", "scripts": { diff --git a/appengine/mailjet/README.md b/appengine/mailjet/README.md index be4567a852..0964c48dae 100644 --- a/appengine/mailjet/README.md +++ b/appengine/mailjet/README.md @@ -5,7 +5,8 @@ > – www.mailjet.com This sample application demonstrates how to use [Express.js][2] and -[node-mailjet][3] to send transactional email on [Google App Engine][4]. +[node-mailjet][3] to send transactional email on [Google App Engine][4] Node.js +Standard Environment and Flexible Environment. You can also read the [Mailjet documentation][5]. diff --git a/appengine/mailjet/app.yaml b/appengine/mailjet/app.flexible.yaml similarity index 100% rename from appengine/mailjet/app.yaml rename to appengine/mailjet/app.flexible.yaml diff --git a/appengine/mailjet/app.js b/appengine/mailjet/app.js index bbe352501c..6082f19e98 100644 --- a/appengine/mailjet/app.js +++ b/appengine/mailjet/app.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, Google, Inc. + * Copyright 2018, 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 @@ -60,14 +60,14 @@ app.post('/hello', function (req, res, next) { var request = Mailjet.post('send').request(options); request - .on('success', function (response, body) { + .then(function (response, body) { console.log(response.statusCode, body); // Render the index route on success return res.render('index', { sent: true }); }) - .on('error', function (err) { + .catch(function (err) { return next(err); }); }); diff --git a/appengine/mailjet/app.standard.yaml b/appengine/mailjet/app.standard.yaml new file mode 100644 index 0000000000..796b1c02e9 --- /dev/null +++ b/appengine/mailjet/app.standard.yaml @@ -0,0 +1,20 @@ +# 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. + +# [START app_yaml] +runtime: nodejs8 + +env_variables: + MJ_APIKEY_PUBLIC: + MJ_APIKEY_PRIVATE: +# [END app_yaml] diff --git a/appengine/mailjet/package.json b/appengine/mailjet/package.json index e833b17ac6..29f4daa468 100644 --- a/appengine/mailjet/package.json +++ b/appengine/mailjet/package.json @@ -1,6 +1,6 @@ { "name": "appengine-mailjet", - "description": "An example of using Mailjet in Node.js on Google App Engine Flexible Environment.", + "description": "An example of using Mailjet in Node.js on Google App Engine.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,16 +10,14 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { - "deploy": "gcloud app deploy", "start": "node app.js", "lint": "samples lint", "pretest": "npm run lint", "system-test": "samples test app", - "test": "npm run system-test", - "e2e-test": "samples test deploy" + "test": "npm run system-test" }, "dependencies": { "body-parser": "1.17.2", diff --git a/appengine/memcached/README.md b/appengine/memcached/README.md index b719581ed9..a665180393 100644 --- a/appengine/memcached/README.md +++ b/appengine/memcached/README.md @@ -1,7 +1,8 @@ # Memcached sample for Google App Engine This sample demonstrates accessing Memcached from Node.js on -[Google App Engine Flexible Environment](https://cloud.google.com/appengine). +[Google App Engine](https://cloud.google.com/appengine) Node.js Standard +Environment and Flexible Environment. ## Running locally diff --git a/appengine/memcached/app.yaml b/appengine/memcached/app.flexible.yaml similarity index 100% rename from appengine/memcached/app.yaml rename to appengine/memcached/app.flexible.yaml diff --git a/appengine/memcached/app.standard.yaml b/appengine/memcached/app.standard.yaml new file mode 100644 index 0000000000..44086c7bee --- /dev/null +++ b/appengine/memcached/app.standard.yaml @@ -0,0 +1,30 @@ +# 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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env_variables] +env_variables: + # If you are using the App Engine Memcache service, + # uncomment this section and comment out the other Memcache variables. + #USE_GAE_MEMCACHE: 1 + #GAE_MEMCACHE_HOST: 35.190.255.1 + #GAE_MEMCACHE_PORT: 11211 + MEMCACHE_URL: your-memcache-url + # If you are using a Memcached server with SASL authentiation enabled, + # fill in these values with your username and password. + MEMCACHE_USERNAME: your-memcache-username + MEMCACHE_PASSWORD: your-memcache-password +# [END env_variables] +# [END app_yaml] diff --git a/appengine/memcached/package.json b/appengine/memcached/package.json index bf4921f337..22e4ef767c 100644 --- a/appengine/memcached/package.json +++ b/appengine/memcached/package.json @@ -1,12 +1,12 @@ { "name": "appengine-memcached", - "description": "Memcached sample for Google App Engine Flexible Environment", + "description": "Memcached sample for Google App Engine.", "version": "0.0.1", "private": true, "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node app.js" diff --git a/appengine/metadata/flexible/app.yaml b/appengine/metadata/flexible/app.yaml new file mode 100644 index 0000000000..690f318f28 --- /dev/null +++ b/appengine/metadata/flexible/app.yaml @@ -0,0 +1,17 @@ +# 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. + +# [START app_yaml] +runtime: nodejs +env: flex +# [END app_yaml] \ No newline at end of file diff --git a/appengine/metadata/package.json b/appengine/metadata/flexible/package.json similarity index 88% rename from appengine/metadata/package.json rename to appengine/metadata/flexible/package.json index ac9745196b..84d9897a9a 100644 --- a/appengine/metadata/package.json +++ b/appengine/metadata/flexible/package.json @@ -1,6 +1,6 @@ { "name": "appengine-metadata", - "description": "Sample for accessing the Compute metadata server on GAE.", + "description": "Sample for accessing the Compute metadata server on GAE Flexible Environment.", "version": "0.0.1", "private": true, "license": "Apache-2.0", @@ -10,14 +10,13 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4" + "node": "8.x.x" }, "scripts": { "lint": "samples lint", "pretest": "npm run lint", "system-test": "samples test app", - "test": "npm run system-test", - "e2e-test": "samples test deploy" + "test": "npm run system-test" }, "dependencies": { "express": "4.15.4", diff --git a/appengine/metadata/server.js b/appengine/metadata/flexible/server.js similarity index 100% rename from appengine/metadata/server.js rename to appengine/metadata/flexible/server.js diff --git a/appengine/metadata/standard/app.yaml b/appengine/metadata/standard/app.yaml new file mode 100644 index 0000000000..25df3f3dff --- /dev/null +++ b/appengine/metadata/standard/app.yaml @@ -0,0 +1,16 @@ +# 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] \ No newline at end of file diff --git a/appengine/metadata/standard/package.json b/appengine/metadata/standard/package.json new file mode 100644 index 0000000000..3beebf7224 --- /dev/null +++ b/appengine/metadata/standard/package.json @@ -0,0 +1,40 @@ +{ + "name": "appengine-metadata", + "description": "Sample for accessing the Compute metadata server on GAE Standard Environment.", + "version": "0.0.1", + "private": true, + "license": "Apache-2.0", + "author": "Google Inc.", + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "engines": { + "node": "8.x.x" + }, + "scripts": { + "lint": "samples lint", + "pretest": "npm run lint", + "system-test": "samples test app", + "test": "npm run system-test" + }, + "dependencies": { + "express": "4.15.4", + "got": "7.1.0" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.4.17" + }, + "cloud-repo-tools": { + "test": { + "app": { + "msg": "External IP:", + "args": [ + "server.js" + ] + } + }, + "requiresKeyFile": false, + "requiresProjectId": false + } +} diff --git a/appengine/metadata/standard/server.js b/appengine/metadata/standard/server.js new file mode 100644 index 0000000000..e2192abcb0 --- /dev/null +++ b/appengine/metadata/standard/server.js @@ -0,0 +1,60 @@ +/** + * Copyright 2017, 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 appengine_metadata] +const express = require('express'); +const request = require('got'); + +const app = express(); +app.enable('trust proxy'); + +const METADATA_NETWORK_INTERFACE_URL = 'http://metadata/computeMetadata/v1/' + +'/instance/network-interfaces/0/access-configs/0/external-ip'; + +function getExternalIp () { + const options = { + headers: { + 'Metadata-Flavor': 'Google' + }, + json: true + }; + + return request(METADATA_NETWORK_INTERFACE_URL, options) + .then((response) => response.body) + .catch((err) => { + if (err || err.statusCode !== 200) { + console.log('Error while talking to metadata server, assuming localhost'); + return 'localhost'; + } + return Promise.reject(err); + }); +} + +app.get('/', (req, res, next) => { + getExternalIp() + .then((externalIp) => { + res.status(200).send(`External IP: ${externalIp}`).end(); + }) + .catch(next); +}); + +const PORT = process.env.PORT || 8080; +app.listen(PORT, () => { + console.log(`App listening on port ${PORT}`); + console.log('Press Ctrl+C to quit.'); +}); +// [END appengine_metadata] diff --git a/appengine/mongodb/README.md b/appengine/mongodb/README.md index add8b5a83f..0d05ba26cc 100644 --- a/appengine/mongodb/README.md +++ b/appengine/mongodb/README.md @@ -2,10 +2,14 @@ > [MongoDB][1] is an open source (AGPL licensed), NoSQL document database. -Read the [MongoDB on App Engine Tutorial][2] for how to run and deploy this sample -app. +Refer to the [appengine/README.md](../README.md) file for more instructions on +running and deploying this app. -You can also read the [node_mongodb documentation][3]. +App Engine Node.js Flexible Environment users may also read the community +tutorial [MongoDB on App Engine Tutorial][2] for how to run and deploy this +sample app. + +For more information about MongoDB Node.js Driver, read the [node_mongodb documentation][3]. [1]: http://mongodb.org/ [2]: https://cloud.google.com/nodejs/resources/databases/mongodb diff --git a/appengine/mongodb/app.yaml b/appengine/mongodb/app.flexible.yaml similarity index 100% rename from appengine/mongodb/app.yaml rename to appengine/mongodb/app.flexible.yaml diff --git a/appengine/mongodb/app.standard.yaml b/appengine/mongodb/app.standard.yaml new file mode 100644 index 0000000000..8cf0f07dc8 --- /dev/null +++ b/appengine/mongodb/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/mongodb/package.json b/appengine/mongodb/package.json index 9cf8675c3e..ec5a4f7305 100644 --- a/appengine/mongodb/package.json +++ b/appengine/mongodb/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node server.js", diff --git a/appengine/parse-server/README.md b/appengine/parse-server/README.md index d9b932792e..d30bab0ff6 100644 --- a/appengine/parse-server/README.md +++ b/appengine/parse-server/README.md @@ -1,7 +1,8 @@ # Parse-server sample for Google App Engine -This sample demonstrates deploying a [Parse-server](https://github.com/ParsePlatform/parse-server) -app to [Google App Engine Flexible Environment](https://cloud.google.com/appengine). +This sample shows how to deploy a [Parse-server](https://github.com/ParsePlatform/parse-server) +app to [Google App Engine](https://cloud.google.com/appengine) Node.js Standard +Environment and Flexible Environment. ## Setup @@ -23,10 +24,15 @@ app to [Google App Engine Flexible Environment](https://cloud.google.com/appengi 1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). 1. `npm start` -## Deploy +## Deploy to App Engine Standard Environment 1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). -1. `npm run deploy` +1. `gcloud app deploy app.standard.yaml` + +## Deploy to App Engine Flexible Environment + +1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). +1. `gcloud app deploy app.flexible.yaml` Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying. diff --git a/appengine/parse-server/app.yaml b/appengine/parse-server/app.flexible.yaml similarity index 100% rename from appengine/parse-server/app.yaml rename to appengine/parse-server/app.flexible.yaml diff --git a/appengine/parse-server/app.standard.yaml b/appengine/parse-server/app.standard.yaml new file mode 100644 index 0000000000..ab74945fd7 --- /dev/null +++ b/appengine/parse-server/app.standard.yaml @@ -0,0 +1,16 @@ +# 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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/parse-server/package.json b/appengine/parse-server/package.json index 66f5364c4d..5f0861b4f1 100644 --- a/appengine/parse-server/package.json +++ b/appengine/parse-server/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "dependencies": { "express": "4.14.1", diff --git a/appengine/pubsub/README.md b/appengine/pubsub/README.md index fdb0e035ce..7460908ca6 100644 --- a/appengine/pubsub/README.md +++ b/appengine/pubsub/README.md @@ -1,6 +1,7 @@ # Node.js Cloud Pub/Sub sample for Google App Engine -This demonstrates how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine Flexible Environment](https://cloud.google.com/appengine) using Node.js. +This sample shows how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine](https://cloud.google.com/appengine) +Standard Environment and Flexible Environment using Node.js. ## Setup diff --git a/appengine/pubsub/app.yaml b/appengine/pubsub/app.flexible.yaml similarity index 100% rename from appengine/pubsub/app.yaml rename to appengine/pubsub/app.flexible.yaml diff --git a/appengine/pubsub/app.standard.yaml b/appengine/pubsub/app.standard.yaml new file mode 100644 index 0000000000..b21f713f64 --- /dev/null +++ b/appengine/pubsub/app.standard.yaml @@ -0,0 +1,28 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 + +# [START instance_class] +instance_class: F2 +# [END instance_class] + +# [START env] +env_variables: + PUBSUB_TOPIC: YOUR_TOPIC_NAME + # This token is used to verify that requests originate from your + # application. It can be any sufficiently random string. + PUBSUB_VERIFICATION_TOKEN: YOUR_VERIFICATION_TOKEN +# [END env] +# [END app_yaml] diff --git a/appengine/pubsub/package.json b/appengine/pubsub/package.json index 9993a90c5c..3310bcb8f3 100644 --- a/appengine/pubsub/package.json +++ b/appengine/pubsub/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node app.js", diff --git a/appengine/redis/README.md b/appengine/redis/README.md index 16d73d6c08..1e085c2c05 100644 --- a/appengine/redis/README.md +++ b/appengine/redis/README.md @@ -3,10 +3,14 @@ > [Redis][1] is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. -Read the [Redis on App Engine Tutorial][2] for how to run and deploy this sample +Refer to the [appengine/README.md](../README.md) file for more instructions on +running and deploying this app. + +App Engine Node.js Flexible Environment users may also read the community +tutorial [Redis on App Engine Tutorial][2] for how to run and deploy this sample app. -You can also read the [node_redis documentation][3]. +Additonally, read the [node_redis documentation][3]. [1]: http://redis.io/ [2]: https://cloud.google.com/nodejs/resources/databases/redis diff --git a/appengine/redis/app.yaml b/appengine/redis/app.flexible.yaml similarity index 100% rename from appengine/redis/app.yaml rename to appengine/redis/app.flexible.yaml diff --git a/appengine/redis/app.standard.yaml b/appengine/redis/app.standard.yaml new file mode 100644 index 0000000000..8cf0f07dc8 --- /dev/null +++ b/appengine/redis/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/redis/package.json b/appengine/redis/package.json index 2e305a35b8..67297db99b 100644 --- a/appengine/redis/package.json +++ b/appengine/redis/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "dependencies": { "nconf": "0.8.4", diff --git a/appengine/sendgrid/README.md b/appengine/sendgrid/README.md index 0f2e3b1f75..123fe4d2bb 100644 --- a/appengine/sendgrid/README.md +++ b/appengine/sendgrid/README.md @@ -1,13 +1,15 @@ # Node.js SendGrid email sample for Google App Engine -This sample demonstrates how to use [SendGrid](https://www.sendgrid.com) on -[Google App Engine Flexible Environment](https://cloud.google.com/appengine). +This sample application shows how to use [SendGrid](https://www.sendgrid.com) on +[Google App Engine](https://cloud.google.com/appengine) Node.js Standard +Environment and Flexible Environment. For more information about SendGrid, see their [documentation](https://sendgrid.com/docs/User_Guide/index.html). -Read the [Sendgrid on App Engine Tutorial][5] for how to run and deploy this -sample app. +App Engine Node.js Flexible Environment users may also read the community +tutorial [Sendgrid on App Engine Tutorial][1] for more information on how to +run and deploy this sample app. ## Setup @@ -16,7 +18,8 @@ Before you can run or deploy the sample, you will need to do the following: 1. [Create a SendGrid Account](http://sendgrid.com/partner/google). As of September 2015, Google users start with 25,000 free emails per month. 1. Configure your SendGrid settings in the environment variables section in -`app.yaml`. +`app.standard.yaml` (if you are deploying to App Engine Standard Environment) or +`app.flexible.yaml` (if you are deploying to App Engine Flexible Environment). ## Running locally diff --git a/appengine/sendgrid/app.yaml b/appengine/sendgrid/app.flexible.yaml similarity index 100% rename from appengine/sendgrid/app.yaml rename to appengine/sendgrid/app.flexible.yaml diff --git a/appengine/sendgrid/app.standard.yaml b/appengine/sendgrid/app.standard.yaml new file mode 100644 index 0000000000..cab1abd315 --- /dev/null +++ b/appengine/sendgrid/app.standard.yaml @@ -0,0 +1,22 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env_variables] +env_variables: + SENDGRID_API_KEY: + SENDGRID_SENDER: +# [END env_variables] +# [END app_yaml] diff --git a/appengine/sendgrid/package.json b/appengine/sendgrid/package.json index 97cda9d846..84fd24fe31 100644 --- a/appengine/sendgrid/package.json +++ b/appengine/sendgrid/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node app.js" diff --git a/appengine/static-files/README.md b/appengine/static-files/README.md index 05b23425b5..cd1d9c8dd9 100644 --- a/appengine/static-files/README.md +++ b/appengine/static-files/README.md @@ -1,6 +1,6 @@ # Serving static files in Node.js sample for Google App Engine -This sample demonstrates serving static files in a Node.js app for [Google App Engine Flexible Environment](https://cloud.google.com/appengine). +This sample demonstrates serving static files in a Node.js app for [Google App Engine](https://cloud.google.com/appengine) Node.js Standard Environment and Flexible Environment. ## Running locally diff --git a/appengine/static-files/app.yaml b/appengine/static-files/app.flexible.yaml similarity index 100% rename from appengine/static-files/app.yaml rename to appengine/static-files/app.flexible.yaml diff --git a/appengine/static-files/app.standard.yaml b/appengine/static-files/app.standard.yaml new file mode 100644 index 0000000000..8cf0f07dc8 --- /dev/null +++ b/appengine/static-files/app.standard.yaml @@ -0,0 +1,16 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 +# [END app_yaml] diff --git a/appengine/static-files/package.json b/appengine/static-files/package.json index f9c2f695e7..45f620c054 100644 --- a/appengine/static-files/package.json +++ b/appengine/static-files/package.json @@ -6,7 +6,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node app.js", diff --git a/appengine/storage/README.md b/appengine/storage/flexible/README.md similarity index 94% rename from appengine/storage/README.md rename to appengine/storage/flexible/README.md index cc9012bd42..aafe8ceff7 100644 --- a/appengine/storage/README.md +++ b/appengine/storage/flexible/README.md @@ -24,7 +24,7 @@ with the following command: ## Running locally -Refer to the [top-level README](../README.md) for instructions on running and +Refer to the [top-level README](../../README.md) for instructions on running and deploying. When running locally, you can use the [Google Cloud SDK](https://cloud.google.com/sdk) diff --git a/appengine/storage/app.js b/appengine/storage/flexible/app.js similarity index 100% rename from appengine/storage/app.js rename to appengine/storage/flexible/app.js diff --git a/appengine/storage/app.yaml b/appengine/storage/flexible/app.yaml similarity index 100% rename from appengine/storage/app.yaml rename to appengine/storage/flexible/app.yaml diff --git a/appengine/storage/package.json b/appengine/storage/flexible/package.json similarity index 100% rename from appengine/storage/package.json rename to appengine/storage/flexible/package.json diff --git a/appengine/storage/system-test/app.test.js b/appengine/storage/flexible/system-test/app.test.js similarity index 100% rename from appengine/storage/system-test/app.test.js rename to appengine/storage/flexible/system-test/app.test.js diff --git a/appengine/storage/system-test/resources/test.txt b/appengine/storage/flexible/system-test/resources/test.txt similarity index 100% rename from appengine/storage/system-test/resources/test.txt rename to appengine/storage/flexible/system-test/resources/test.txt diff --git a/appengine/storage/views/form.pug b/appengine/storage/flexible/views/form.pug similarity index 100% rename from appengine/storage/views/form.pug rename to appengine/storage/flexible/views/form.pug diff --git a/appengine/storage/standard/README.md b/appengine/storage/standard/README.md new file mode 100644 index 0000000000..8207245a02 --- /dev/null +++ b/appengine/storage/standard/README.md @@ -0,0 +1,40 @@ +# Node.js Google Cloud Storage sample for Google App Engine + +This sample demonstrates how to use [Google Cloud Storage](https://cloud.google.com/storage/) +on [Google App Engine Standard Environment](https://cloud.google.com/appengine). + +## Setup + +Before you can run or deploy the sample, you will need to do the following: + +1. Enable the Cloud Storage API in the [Google Developers Console](https://console.developers.google.com/project/_/apiui/apiview/storage/overview). + +1. Create a Cloud Storage Bucket. You can do this with the [Google Cloud SDK](https://cloud.google.com/sdk) +with the following command: + + gsutil mb gs:// + +1. Set the default ACL on your bucket to public read in order to serve files +directly from Cloud Storage. You can do this with the [Google Cloud SDK](https://cloud.google.com/sdk) +with the following command: + + gsutil defacl set public-read gs:// + +1. Update the environment variables in `app.yaml`. + +## Running locally + +Refer to the [top-level README](../../README.md) for instructions on running and +deploying. + +When running locally, you can use the [Google Cloud SDK](https://cloud.google.com/sdk) +to provide authentication to use Google Cloud APIs: + + gcloud init + +Then set environment variables before starting your application: + + export GOOGLE_CLOUD_PROJECT= + export GCLOUD_STORAGE_BUCKET= + npm install + npm start diff --git a/appengine/storage/standard/app.js b/appengine/storage/standard/app.js new file mode 100644 index 0000000000..71cdc51d28 --- /dev/null +++ b/appengine/storage/standard/app.js @@ -0,0 +1,96 @@ +/** + * 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'; + +const process = require('process'); // Required to mock environment variables + +// [START app] +const format = require('util').format; +const express = require('express'); +const Multer = require('multer'); +const bodyParser = require('body-parser'); + +// By default, the client will authenticate using the service account file +// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use +// the project specified by the GOOGLE_CLOUD_PROJECT environment variable. See +// https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/docs/authentication.md +// These environment variables are set automatically on Google App Engine +const Storage = require('@google-cloud/storage'); + +// Instantiate a storage client +const storage = Storage(); + +const app = express(); +app.set('view engine', 'pug'); +app.use(bodyParser.json()); + +// [START config] +// Multer is required to process file uploads and make them available via +// req.files. +const multer = Multer({ + storage: Multer.memoryStorage(), + limits: { + fileSize: 5 * 1024 * 1024 // no larger than 5mb, you can change as needed. + } +}); + +// A bucket is a container for objects (files). +const bucket = storage.bucket(process.env.GCLOUD_STORAGE_BUCKET); +// [END config] + +// [START form] +// Display a form for uploading files. +app.get('/', (req, res) => { + res.render('form.pug'); +}); +// [END form] + +// [START process] +// Process the file upload and upload to Google Cloud Storage. +app.post('/upload', multer.single('file'), (req, res, next) => { + if (!req.file) { + res.status(400).send('No file uploaded.'); + return; + } + + // Create a new blob in the bucket and upload the file data. + const blob = bucket.file(req.file.originalname); + const blobStream = blob.createWriteStream({ + resumable: false + }); + + blobStream.on('error', (err) => { + next(err); + }); + + blobStream.on('finish', () => { + // The public URL can be used to directly access the file via HTTP. + const publicUrl = format(`https://storage.googleapis.com/${bucket.name}/${blob.name}`); + res.status(200).send(publicUrl); + }); + + blobStream.end(req.file.buffer); +}); +// [END process] + +const PORT = process.env.PORT || 8080; +app.listen(PORT, () => { + console.log(`App listening on port ${PORT}`); + console.log('Press Ctrl+C to quit.'); +}); +// [END app] + +module.exports = app; diff --git a/appengine/storage/standard/app.yaml b/appengine/storage/standard/app.yaml new file mode 100644 index 0000000000..420e663d1f --- /dev/null +++ b/appengine/storage/standard/app.yaml @@ -0,0 +1,21 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env] +env_variables: + GCLOUD_STORAGE_BUCKET: YOUR_BUCKET_NAME +# [END env] +# [END app_yaml] diff --git a/appengine/storage/standard/package.json b/appengine/storage/standard/package.json new file mode 100644 index 0000000000..30f833dd75 --- /dev/null +++ b/appengine/storage/standard/package.json @@ -0,0 +1,40 @@ +{ + "name": "appengine-storage", + "description": "Node.js Google Cloud Storage sample for Google App Engine", + "scripts": { + "start": "node app.js", + "test": "ava system-test/*.test.js -T 30s" + }, + "engines": { + "node": "8.x.x" + }, + "dependencies": { + "@google-cloud/storage": "1.2.1", + "body-parser": "1.17.2", + "express": "4.15.4", + "multer": "1.3.0", + "pug": "2.0.0-rc.3" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.4.17", + "ava": "0.22.0" + }, + "cloud-repo-tools": { + "requiresProjectId": true, + "requiresKeyFile": true, + "test": { + "app": { + "requiredEnvVars": [ + "GCLOUD_STORAGE_BUCKET" + ], + "msg": "", + "substitutions": "YOUR_BUCKET_NAME=$GCLOUD_STORAGE_BUCKET" + }, + "build": { + "requiredEnvVars": [ + "GCLOUD_STORAGE_BUCKET" + ] + } + } + } +} diff --git a/appengine/storage/standard/system-test/app.test.js b/appengine/storage/standard/system-test/app.test.js new file mode 100644 index 0000000000..f6750408b7 --- /dev/null +++ b/appengine/storage/standard/system-test/app.test.js @@ -0,0 +1,62 @@ +// Copyright 2017, 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'; + +const path = require(`path`); +const Storage = require(`@google-cloud/storage`); +const storage = Storage(); +const test = require(`ava`); +const utils = require(`@google-cloud/nodejs-repo-tools`); + +const bucketName = process.env.GCLOUD_STORAGE_BUCKET; +const bucket = storage.bucket(bucketName); + +const cwd = path.join(__dirname, `../`); +const requestObj = utils.getRequest({ cwd: cwd }); + +test.before(async () => { + utils.checkCredentials(); + await bucket.create(bucket).then((data) => { + return bucket.acl.add({ + entity: 'allUsers', + role: Storage.acl.READER_ROLE + }); + }); +}); +test.after.always(async () => { + try { + await bucket.delete(); + } catch (err) {} // ignore error +}); + +test.cb.serial(`should load`, (t) => { + requestObj + .get(`/`) + .expect(200) + .expect((response) => { + t.regex(response.text, //); + }) + .end(t.end); +}); + +test.cb.serial(`should upload a file`, (t) => { + requestObj + .post(`/upload`) + .attach(`file`, path.join(__dirname, `resources/test.txt`)) + .expect(200) + .expect((response) => { + t.is(response.text, `https://storage.googleapis.com/${bucketName}/test.txt`); + }) + .end(t.end); +}); diff --git a/appengine/storage/standard/system-test/resources/test.txt b/appengine/storage/standard/system-test/resources/test.txt new file mode 100644 index 0000000000..3dcff04919 --- /dev/null +++ b/appengine/storage/standard/system-test/resources/test.txt @@ -0,0 +1 @@ +nodejs-docs-samples/appengine/storage test file \ No newline at end of file diff --git a/appengine/storage/standard/views/form.pug b/appengine/storage/standard/views/form.pug new file mode 100644 index 0000000000..1089129a82 --- /dev/null +++ b/appengine/storage/standard/views/form.pug @@ -0,0 +1,10 @@ +doctype html +html(lang="en") + head + title Static Files + meta(charset='utf-8') + link(rel="stylesheet", href="/static/main.css") + body + form(method="POST", action="/upload", enctype="multipart/form-data") + input(type="file", name="file") + input(type="submit") diff --git a/appengine/system-test/all.test.js b/appengine/system-test/all.test.js index 146252bf9a..1c20b36257 100644 --- a/appengine/system-test/all.test.js +++ b/appengine/system-test/all.test.js @@ -77,7 +77,16 @@ var sampleTests = [ msg: 'This is a static file serving example.' }, { - dir: 'appengine/storage', + dir: 'appengine/storage/flexible', + cmd: 'node', + args: ['app.js'], + msg: 'Static Files', + env: { + GCLOUD_STORAGE_BUCKET: 'nodejs-docs-samples' + } + }, + { + dir: 'appengine/storage/standard', cmd: 'node', args: ['app.js'], msg: 'Static Files', diff --git a/appengine/twilio/README.md b/appengine/twilio/README.md index 69e1dbf9fa..eeccdd9ce2 100644 --- a/appengine/twilio/README.md +++ b/appengine/twilio/README.md @@ -1,7 +1,8 @@ # Node.js Twilio voice and SMS sample for Google App Engine -This sample demonstrates how to use [Twilio](https://www.twilio.com) on -[Google App Engine Flexible Environment](https://cloud.google.com/appengine). +This sample shows how to use [Twilio](https://www.twilio.com) on +[Google App Engine](https://cloud.google.com/appengine) Node.js Standard +Environment and Flexible Environment. For more information about Twilio, see the [Twilio Node library](https://www.twilio.com/docs/node/install). diff --git a/appengine/twilio/app.yaml b/appengine/twilio/app.flexible.yaml similarity index 100% rename from appengine/twilio/app.yaml rename to appengine/twilio/app.flexible.yaml diff --git a/appengine/twilio/app.standard.yaml b/appengine/twilio/app.standard.yaml new file mode 100644 index 0000000000..a77f52a426 --- /dev/null +++ b/appengine/twilio/app.standard.yaml @@ -0,0 +1,23 @@ +# Copyright 2015-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. + +# [START app_yaml] +runtime: nodejs8 + +# [START env_variables] +env_variables: + TWILIO_ACCOUNT_SID: + TWILIO_AUTH_TOKEN: + TWILIO_NUMBER: +# [END env_variables] +# [END app_yaml] diff --git a/appengine/twilio/package.json b/appengine/twilio/package.json index 4698df0236..36f9673ca5 100644 --- a/appengine/twilio/package.json +++ b/appengine/twilio/package.json @@ -1,12 +1,12 @@ { "name": "appengine-twilio", - "description": "Samples for Google App Engine Flexible Environment", + "description": "Twilio sample for Google App Engine", "version": "0.0.1", "private": true, "license": "Apache Version 2.0", "author": "Google Inc.", "engines": { - "node": ">=4.3.2" + "node": "8.x.x" }, "scripts": { "start": "node app.js" From 63f087de343e85a6b7b564d24cd399c0e9daf065 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Fri, 30 Mar 2018 01:47:01 -0700 Subject: [PATCH 2/6] Solve conflicts --- appengine/cloudsql/package.json | 12 ++++++------ appengine/cloudsql_postgresql/package.json | 12 ++++++------ appengine/datastore/package.json | 6 +++--- appengine/errorreporting/package.json | 12 ++++++------ appengine/hello-world/flexible/package.json | 4 ++-- appengine/hello-world/standard/package.json | 4 ++-- appengine/mailjet/package.json | 6 +++--- appengine/metadata/flexible/package.json | 6 +++--- appengine/metadata/standard/package.json | 6 +++--- appengine/storage/flexible/package.json | 12 ++++++------ appengine/storage/standard/package.json | 12 ++++++------ 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/appengine/cloudsql/package.json b/appengine/cloudsql/package.json index 3d5ea04272..aa6e7affbe 100644 --- a/appengine/cloudsql/package.json +++ b/appengine/cloudsql/package.json @@ -23,15 +23,15 @@ "test": "samples test run --cmd npm -- run all-test" }, "dependencies": { - "async": "2.5.0", - "express": "4.15.4", - "knex": "0.13.0", - "mysql": "2.14.1", + "async": "2.6.0", + "express": "4.16.3", + "knex": "0.14.4", + "mysql": "2.15.0", "prompt": "1.0.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.22.0" + "@google-cloud/nodejs-repo-tools": "2.2.5", + "ava": "0.25.0" }, "cloud-repo-tools": { "requiresKeyFile": true, diff --git a/appengine/cloudsql_postgresql/package.json b/appengine/cloudsql_postgresql/package.json index 220055c238..96a95015e5 100644 --- a/appengine/cloudsql_postgresql/package.json +++ b/appengine/cloudsql_postgresql/package.json @@ -23,15 +23,15 @@ "test": "samples test run --cmd npm -- run all-test" }, "dependencies": { - "async": "2.5.0", - "express": "4.15.4", - "knex": "0.13.0", - "pg": "7.3.0", + "async": "2.6.0", + "express": "4.16.2", + "knex": "0.14.4", + "pg": "7.4.1", "prompt": "1.0.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.22.0" + "@google-cloud/nodejs-repo-tools": "2.2.1", + "ava": "0.25.0" }, "cloud-repo-tools": { "requiresKeyFile": true, diff --git a/appengine/datastore/package.json b/appengine/datastore/package.json index 8a5e574d85..ea132e4c97 100644 --- a/appengine/datastore/package.json +++ b/appengine/datastore/package.json @@ -20,11 +20,11 @@ "test": "npm run system-test" }, "dependencies": { - "@google-cloud/datastore": "1.1.0", - "express": "4.15.4" + "@google-cloud/datastore": "1.3.4", + "express": "4.16.2" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/errorreporting/package.json b/appengine/errorreporting/package.json index 2e08ba5421..f74b94d830 100644 --- a/appengine/errorreporting/package.json +++ b/appengine/errorreporting/package.json @@ -21,14 +21,14 @@ "test": "npm run unit-test && npm run system-test" }, "dependencies": { - "@google-cloud/error-reporting": "0.2.1", - "express": "4.15.4" + "@google-cloud/error-reporting": "0.2.3", + "express": "4.16.2" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.21.0", - "proxyquire": "1.8.0", - "sinon": "3.2.0" + "@google-cloud/nodejs-repo-tools": "2.2.1", + "ava": "0.25.0", + "proxyquire": "2.0.0", + "sinon": "4.4.2" }, "cloud-repo-tools": { "test": { diff --git a/appengine/hello-world/flexible/package.json b/appengine/hello-world/flexible/package.json index a90e2bbeba..41f021289c 100644 --- a/appengine/hello-world/flexible/package.json +++ b/appengine/hello-world/flexible/package.json @@ -22,10 +22,10 @@ "e2e-test": "samples test deploy" }, "dependencies": { - "express": "4.15.4" + "express": "4.16.2" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/hello-world/standard/package.json b/appengine/hello-world/standard/package.json index 97d71af4d3..f4a3a3efc8 100644 --- a/appengine/hello-world/standard/package.json +++ b/appengine/hello-world/standard/package.json @@ -22,10 +22,10 @@ "e2e-test": "samples test deploy" }, "dependencies": { - "express": "4.15.4" + "express": "4.16.2" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/mailjet/package.json b/appengine/mailjet/package.json index 29f4daa468..f906ecb77c 100644 --- a/appengine/mailjet/package.json +++ b/appengine/mailjet/package.json @@ -20,13 +20,13 @@ "test": "npm run system-test" }, "dependencies": { - "body-parser": "1.17.2", - "express": "4.15.4", + "body-parser": "1.18.2", + "express": "4.16.2", "jade": "1.11.0", "node-mailjet": "3.2.1" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/metadata/flexible/package.json b/appengine/metadata/flexible/package.json index 84d9897a9a..16b3d05b09 100644 --- a/appengine/metadata/flexible/package.json +++ b/appengine/metadata/flexible/package.json @@ -19,11 +19,11 @@ "test": "npm run system-test" }, "dependencies": { - "express": "4.15.4", - "got": "7.1.0" + "express": "4.16.2", + "got": "8.2.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/metadata/standard/package.json b/appengine/metadata/standard/package.json index 3beebf7224..79e55be338 100644 --- a/appengine/metadata/standard/package.json +++ b/appengine/metadata/standard/package.json @@ -19,11 +19,11 @@ "test": "npm run system-test" }, "dependencies": { - "express": "4.15.4", - "got": "7.1.0" + "express": "4.16.2", + "got": "8.2.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17" + "@google-cloud/nodejs-repo-tools": "2.2.1" }, "cloud-repo-tools": { "test": { diff --git a/appengine/storage/flexible/package.json b/appengine/storage/flexible/package.json index e9dce13e91..0a1900ff13 100644 --- a/appengine/storage/flexible/package.json +++ b/appengine/storage/flexible/package.json @@ -9,15 +9,15 @@ "node": ">=4.3.2" }, "dependencies": { - "@google-cloud/storage": "1.2.1", - "body-parser": "1.17.2", - "express": "4.15.4", + "@google-cloud/storage": "1.6.0", + "body-parser": "1.18.2", + "express": "4.16.3", "multer": "1.3.0", - "pug": "2.0.0-rc.3" + "pug": "2.0.3" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.22.0" + "@google-cloud/nodejs-repo-tools": "2.2.5", + "ava": "0.25.0" }, "cloud-repo-tools": { "requiresProjectId": true, diff --git a/appengine/storage/standard/package.json b/appengine/storage/standard/package.json index 30f833dd75..0106d6c427 100644 --- a/appengine/storage/standard/package.json +++ b/appengine/storage/standard/package.json @@ -9,15 +9,15 @@ "node": "8.x.x" }, "dependencies": { - "@google-cloud/storage": "1.2.1", - "body-parser": "1.17.2", - "express": "4.15.4", + "@google-cloud/storage": "1.6.0", + "body-parser": "1.18.2", + "express": "4.16.3", "multer": "1.3.0", - "pug": "2.0.0-rc.3" + "pug": "2.0.3" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.22.0" + "@google-cloud/nodejs-repo-tools": "2.2.5", + "ava": "0.25.0" }, "cloud-repo-tools": { "requiresProjectId": true, From 905d5973855b082847addf1e6a18004b6e1fd52d Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Mon, 2 Apr 2018 14:48:34 -0700 Subject: [PATCH 3/6] MInor Fixes --- appengine/analytics/README.md | 6 +++--- appengine/building-an-app/build/README.md | 2 +- appengine/building-an-app/build/package.json | 2 ++ appengine/building-an-app/update/README.md | 2 +- appengine/building-an-app/update/package.json | 2 ++ appengine/building-an-app/update/test/server.test.js | 2 +- appengine/cloudsql/README.md | 6 ++++-- appengine/cloudsql/app.flexible.yaml | 2 ++ appengine/cloudsql/app.standard.yaml | 2 ++ appengine/cloudsql_postgresql/README.md | 8 +++++--- appengine/cloudsql_postgresql/app.flexible.yaml | 2 ++ appengine/cloudsql_postgresql/app.standard.yaml | 2 ++ appengine/cloudtasks/README.md | 5 ++++- appengine/datastore/README.md | 6 ++++-- appengine/errorreporting/README.md | 5 ++++- appengine/loopback/README.md | 3 ++- appengine/mailjet/README.md | 8 +++++--- appengine/mailjet/app.flexible.yaml | 4 ++++ appengine/mailjet/app.standard.yaml | 3 +++ appengine/memcached/README.md | 7 +++++-- appengine/memcached/app.flexible.yaml | 3 +++ appengine/memcached/app.standard.yaml | 3 +++ appengine/metadata/standard/server.js | 5 ++--- appengine/mongodb/README.md | 11 ++++++----- appengine/parse-server/README.md | 5 +++-- appengine/pubsub/README.md | 3 ++- appengine/redis/README.md | 11 ++++++----- appengine/sendgrid/README.md | 4 ++-- appengine/sendgrid/app.flexible.yaml | 3 +++ appengine/sendgrid/app.standard.yaml | 3 +++ appengine/static-files/README.md | 3 ++- appengine/twilio/README.md | 4 ++-- appengine/twilio/app.flexible.yaml | 3 +++ appengine/twilio/app.standard.yaml | 3 +++ 34 files changed, 101 insertions(+), 42 deletions(-) diff --git a/appengine/analytics/README.md b/appengine/analytics/README.md index dcf9273264..45d03dd3eb 100644 --- a/appengine/analytics/README.md +++ b/appengine/analytics/README.md @@ -3,9 +3,9 @@ This sample application shows how to integrate your Node.js application with Google Analytics on Google App Engine. -App Engine Node.js Standard Environment users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app. +[App Engine Standard][appengine-std] users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app. -App Engine Node.js Flexible Environment users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app. +[App Engine Flexible][appengine-flex] users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -46,7 +46,7 @@ or with `yarn`: ## Deploying to App Engine Flexible Environment - gcloud app deploy app.flexible.yaml + gcloud app deploy app.flexible.yaml ## Running the tests diff --git a/appengine/building-an-app/build/README.md b/appengine/building-an-app/build/README.md index 9bbcd1abcb..84eef32ad9 100644 --- a/appengine/building-an-app/build/README.md +++ b/appengine/building-an-app/build/README.md @@ -26,7 +26,7 @@ Before you can run or deploy the sample, you need to do the following: ## Deploying to App Engine - npm run deploy + gcloud app deploy ## Running the tests diff --git a/appengine/building-an-app/build/package.json b/appengine/building-an-app/build/package.json index 415dcd3014..8206285234 100755 --- a/appengine/building-an-app/build/package.json +++ b/appengine/building-an-app/build/package.json @@ -5,6 +5,8 @@ "private": true, "main": "server.js", "scripts": { + "start": "node server.js", + "deploy": "gcloud app deploy", "lint": "samples lint", "pretest": "npm run lint", "test": "ava --verbose test/*.test.js" diff --git a/appengine/building-an-app/update/README.md b/appengine/building-an-app/update/README.md index e3cd57ceb8..f8a7cc992d 100644 --- a/appengine/building-an-app/update/README.md +++ b/appengine/building-an-app/update/README.md @@ -26,7 +26,7 @@ Before you can run or deploy the sample, you need to do the following: ## Deploying to App Engine - npm run deploy + gcloud app deploy ## Running the tests diff --git a/appengine/building-an-app/update/package.json b/appengine/building-an-app/update/package.json index d0117269a1..c7d0553074 100755 --- a/appengine/building-an-app/update/package.json +++ b/appengine/building-an-app/update/package.json @@ -5,6 +5,8 @@ "private": true, "main": "server.js", "scripts": { + "start": "node server.js", + "deploy": "gcloud app deploy", "lint": "samples lint", "pretest": "npm run lint", "test": "ava --verbose test/*.test.js" diff --git a/appengine/building-an-app/update/test/server.test.js b/appengine/building-an-app/update/test/server.test.js index c35766abd0..8bfac5b946 100755 --- a/appengine/building-an-app/update/test/server.test.js +++ b/appengine/building-an-app/update/test/server.test.js @@ -40,7 +40,7 @@ test.cb.serial(`should display form`, (t) => { .get(`/submit`) .expect(200) .expect((response) => { - t.regex(response.text, /textarea name="message" placeholder="Message"/); + t.true(response.text.includes('textarea name="message" placeholder="Message"'); }) .end(t.end); }); diff --git a/appengine/cloudsql/README.md b/appengine/cloudsql/README.md index 2e615a23f0..11bb95fcc3 100644 --- a/appengine/cloudsql/README.md +++ b/appengine/cloudsql/README.md @@ -3,11 +3,13 @@ This sample application shows how to use [Google Cloud SQL[[sql] for [MySQL][mysql] on Google App Engine. -App Engine Standard users: See tutorial [Using Cloud SQL for MySQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. +[App Engine Standard][appengine-std] users: See tutorial [Using Cloud SQL for MySQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. -App Engine Flexible users: See tutorial [Using Cloud SQL for MySQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. +[App Engine Flexible][appengine-flex] users: See tutorial [Using Cloud SQL for MySQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ [mysql]: https://www.mysql.com/downloads/ +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs [flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql [std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-sql diff --git a/appengine/cloudsql/app.flexible.yaml b/appengine/cloudsql/app.flexible.yaml index b02543d6c2..dd69cea493 100644 --- a/appengine/cloudsql/app.flexible.yaml +++ b/appengine/cloudsql/app.flexible.yaml @@ -16,6 +16,8 @@ runtime: nodejs env: flex # [START env] +# The following env variables may contain sensitive information that grants +# anyone access to your database. Do not add this file to your source control. env_variables: SQL_USER: YOUR_SQL_USER SQL_PASSWORD: YOUR_SQL_PASSWORD diff --git a/appengine/cloudsql/app.standard.yaml b/appengine/cloudsql/app.standard.yaml index c96f7f553b..5608bdc126 100644 --- a/appengine/cloudsql/app.standard.yaml +++ b/appengine/cloudsql/app.standard.yaml @@ -15,6 +15,8 @@ runtime: nodejs8 # [START env] +# The following env variables may contain sensitive information that grants +# anyone access to your database. Do not add this file to your source control. env_variables: SQL_USER: YOUR_SQL_USER SQL_PASSWORD: YOUR_SQL_PASSWORD diff --git a/appengine/cloudsql_postgresql/README.md b/appengine/cloudsql_postgresql/README.md index fafc2eb5d0..7e7d63ce12 100644 --- a/appengine/cloudsql_postgresql/README.md +++ b/appengine/cloudsql_postgresql/README.md @@ -1,15 +1,17 @@ -# Cloud SQL for MySQL Node.js sample on App Engine flexible environment +# Cloud SQL for PostgresSQL Node.js sample on App Engine flexible environment This sample application shows how to use [Google Cloud SQL[[sql] for [PostgreSQL][postgres] on Google App Engine. -App Engine Standard users: See tutorial [ +[App Engine Standard][appengine-std] users: See tutorial [ Using Cloud SQL for PostgreSQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. -App Engine Flexible users: See tutorial [ +[App Engine Flexible][appengine-flex] users: See tutorial [ Using Cloud SQL for PostgreSQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ [postgres]: https://www.postgresql.org/download/ +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs [flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql-postgres [std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-sql-postgres diff --git a/appengine/cloudsql_postgresql/app.flexible.yaml b/appengine/cloudsql_postgresql/app.flexible.yaml index b02543d6c2..dd69cea493 100644 --- a/appengine/cloudsql_postgresql/app.flexible.yaml +++ b/appengine/cloudsql_postgresql/app.flexible.yaml @@ -16,6 +16,8 @@ runtime: nodejs env: flex # [START env] +# The following env variables may contain sensitive information that grants +# anyone access to your database. Do not add this file to your source control. env_variables: SQL_USER: YOUR_SQL_USER SQL_PASSWORD: YOUR_SQL_PASSWORD diff --git a/appengine/cloudsql_postgresql/app.standard.yaml b/appengine/cloudsql_postgresql/app.standard.yaml index c96f7f553b..5608bdc126 100644 --- a/appengine/cloudsql_postgresql/app.standard.yaml +++ b/appengine/cloudsql_postgresql/app.standard.yaml @@ -15,6 +15,8 @@ runtime: nodejs8 # [START env] +# The following env variables may contain sensitive information that grants +# anyone access to your database. Do not add this file to your source control. env_variables: SQL_USER: YOUR_SQL_USER SQL_PASSWORD: YOUR_SQL_PASSWORD diff --git a/appengine/cloudtasks/README.md b/appengine/cloudtasks/README.md index 7d7133950c..98e00a86e5 100644 --- a/appengine/cloudtasks/README.md +++ b/appengine/cloudtasks/README.md @@ -1,7 +1,7 @@ # Node.js Google Cloud Tasks sample for Google App Engine This sample application shows how to use [Google Cloud Tasks](https://cloud.google.com/cloud-tasks/) -on Google App Engine Node.js Standard Environment and Flexible Environment. +on Google App Engine Node.js [Standard Environment][appengine-std] and [Flexible Environment][appengine-flex]. App Engine queues push tasks to an App Engine HTTP target. This directory contains both the App Engine app to deploy, as well as the snippets to run @@ -105,3 +105,6 @@ Examples: For more information, see https://cloud.google.com/cloud-tasks ``` + +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs diff --git a/appengine/datastore/README.md b/appengine/datastore/README.md index 05459e0dda..3796d24d53 100644 --- a/appengine/datastore/README.md +++ b/appengine/datastore/README.md @@ -3,9 +3,9 @@ This sample application shows how to use Google Cloud Datastore on Google App Engine. -App Engine Node.js Standard Environment users: See tutorial [Using Cloud Datastore][tutorial-std] for more information on running and deploying this app. +[App Engine Standard][appengine-std] users: See tutorial [Using Cloud Datastore][tutorial-std] for more information on running and deploying this app. -App Engine Node.js Flexible Environment users: See tutorial [Using Cloud Datastore][tutorial-flex] for more information on running and deploying this app. +[App Engine Flexible][appengine-flex] users: See tutorial [Using Cloud Datastore][tutorial-flex] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -50,6 +50,8 @@ or with `yarn`: See [Contributing][contributing]. +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs [tutorial-std]: https://cloud.google.com/appengine/docs/standard/nodejs/using-cloud-datastore [tutorial-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-datastore [readme]: ../README.md diff --git a/appengine/errorreporting/README.md b/appengine/errorreporting/README.md index 0eb40321e9..acd756f52c 100644 --- a/appengine/errorreporting/README.md +++ b/appengine/errorreporting/README.md @@ -1,9 +1,12 @@ # Node.js error reporting sample for Google App Engine This sample shows how to use Stackdriver Error Reporting on Google App Engine -Node.js Standard Environment and Flexible Environment. +Node.js [Standard Environment][appengine-std] and [Flexible Environment][appengine-flex]. ## Running locally Refer to the [appengine/README.md](../README.md) file for instructions on running and deploying. + +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs \ No newline at end of file diff --git a/appengine/loopback/README.md b/appengine/loopback/README.md index 2a11882ab4..3385180ad8 100644 --- a/appengine/loopback/README.md +++ b/appengine/loopback/README.md @@ -5,7 +5,7 @@ Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -App Engine Node.js Flexible Environment users may also read the community +[App Engine Flexible][5] users may also read the community tutorial [Loopback.js on App Engine Tutorial][2] for how to run and deploy this sample app. @@ -15,3 +15,4 @@ Additionally, view the [live demo][3] and read the [Loopback.js documentation][4 [2]: https://cloud.google.com/nodejs/resources/frameworks/loopback [3]: http://loopback-dot-nodejs-docs-samples.appspot.com [4]: http://loopback.io/getting-started/ +[5]: https://cloud.google.com/appengine/docs/flexible/nodejs diff --git a/appengine/mailjet/README.md b/appengine/mailjet/README.md index 0964c48dae..df1c610959 100644 --- a/appengine/mailjet/README.md +++ b/appengine/mailjet/README.md @@ -6,12 +6,14 @@ This sample application demonstrates how to use [Express.js][2] and [node-mailjet][3] to send transactional email on [Google App Engine][4] Node.js -Standard Environment and Flexible Environment. +[Standard Environment][5] and [Flexible Environment][6]. -You can also read the [Mailjet documentation][5]. +You can also read the [Mailjet documentation][7]. [1]: https://www.mailjet.com/ [2]: http://expressjs.com [3]: https://github.com/mailjet/mailjet-apiv3-nodejs [4]: https://cloud.google.com/appengine -[5]: https://dev.mailjet.com/ +[5]: https://cloud.google.com/appengine/docs/standard/nodejs +[6]: https://cloud.google.com/appengine/docs/flexible/nodejs +[7]: https://dev.mailjet.com/ diff --git a/appengine/mailjet/app.flexible.yaml b/appengine/mailjet/app.flexible.yaml index 5e74170900..b0e77702c2 100644 --- a/appengine/mailjet/app.flexible.yaml +++ b/appengine/mailjet/app.flexible.yaml @@ -14,6 +14,10 @@ # [START app_yaml] runtime: nodejs env: flex + +# The following env variables may contain sensitive information that grants +# anyone access to your Mailjet account. Do not add this file to your source +# control. env_variables: MJ_APIKEY_PUBLIC: MJ_APIKEY_PRIVATE: diff --git a/appengine/mailjet/app.standard.yaml b/appengine/mailjet/app.standard.yaml index 796b1c02e9..4c7e57e5b4 100644 --- a/appengine/mailjet/app.standard.yaml +++ b/appengine/mailjet/app.standard.yaml @@ -14,6 +14,9 @@ # [START app_yaml] runtime: nodejs8 +# The following env variables may contain sensitive information that grants +# anyone access to your Mailjet account. Do not add this file to your source +# control. env_variables: MJ_APIKEY_PUBLIC: MJ_APIKEY_PRIVATE: diff --git a/appengine/memcached/README.md b/appengine/memcached/README.md index a665180393..440ea7ebbd 100644 --- a/appengine/memcached/README.md +++ b/appengine/memcached/README.md @@ -1,10 +1,13 @@ # Memcached sample for Google App Engine This sample demonstrates accessing Memcached from Node.js on -[Google App Engine](https://cloud.google.com/appengine) Node.js Standard -Environment and Flexible Environment. +[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard +Environment][appengine-std] and [Flexible Environment][appengine-flex]. ## Running locally Refer to the [appengine/README.md](../README.md) file for instructions on running and deploying. + +[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs +[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs diff --git a/appengine/memcached/app.flexible.yaml b/appengine/memcached/app.flexible.yaml index 9e53787477..c470d7db25 100644 --- a/appengine/memcached/app.flexible.yaml +++ b/appengine/memcached/app.flexible.yaml @@ -16,6 +16,9 @@ runtime: nodejs env: flex # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your memcached service. Do not add this file to your source +# control. env_variables: # If you are using the App Engine Memcache service (currently in alpha), # uncomment this section and comment out the other Memcache variables. diff --git a/appengine/memcached/app.standard.yaml b/appengine/memcached/app.standard.yaml index 44086c7bee..71944f14e3 100644 --- a/appengine/memcached/app.standard.yaml +++ b/appengine/memcached/app.standard.yaml @@ -15,6 +15,9 @@ runtime: nodejs8 # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your memcached service. Do not add this file to your source +# control. env_variables: # If you are using the App Engine Memcache service, # uncomment this section and comment out the other Memcache variables. diff --git a/appengine/metadata/standard/server.js b/appengine/metadata/standard/server.js index e2192abcb0..7ea0a849e0 100644 --- a/appengine/metadata/standard/server.js +++ b/appengine/metadata/standard/server.js @@ -22,8 +22,7 @@ const request = require('got'); const app = express(); app.enable('trust proxy'); -const METADATA_NETWORK_INTERFACE_URL = 'http://metadata/computeMetadata/v1/' + -'/instance/network-interfaces/0/access-configs/0/external-ip'; +const METADATA_NETWORK_INTERFACE_URL = 'http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip'; function getExternalIp () { const options = { @@ -36,7 +35,7 @@ function getExternalIp () { return request(METADATA_NETWORK_INTERFACE_URL, options) .then((response) => response.body) .catch((err) => { - if (err || err.statusCode !== 200) { + if (err && err.statusCode !== 200) { console.log('Error while talking to metadata server, assuming localhost'); return 'localhost'; } diff --git a/appengine/mongodb/README.md b/appengine/mongodb/README.md index 0d05ba26cc..29e107948e 100644 --- a/appengine/mongodb/README.md +++ b/appengine/mongodb/README.md @@ -5,12 +5,13 @@ Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -App Engine Node.js Flexible Environment users may also read the community -tutorial [MongoDB on App Engine Tutorial][2] for how to run and deploy this +[App Engine Node.js Flexible Environment][2] users may also read the community +tutorial [MongoDB on App Engine Tutorial][3] for how to run and deploy this sample app. -For more information about MongoDB Node.js Driver, read the [node_mongodb documentation][3]. +For more information about MongoDB Node.js Driver, read the [node_mongodb documentation][4]. [1]: http://mongodb.org/ -[2]: https://cloud.google.com/nodejs/resources/databases/mongodb -[3]: http://mongodb.github.io/node-mongodb-native/ +[2]: https://cloud.google.com/appengine/docs/flexible/nodejs +[3]: https://cloud.google.com/nodejs/resources/databases/mongodb +[4]: http://mongodb.github.io/node-mongodb-native/ diff --git a/appengine/parse-server/README.md b/appengine/parse-server/README.md index d30bab0ff6..e78d8d80b7 100644 --- a/appengine/parse-server/README.md +++ b/appengine/parse-server/README.md @@ -1,8 +1,9 @@ # Parse-server sample for Google App Engine This sample shows how to deploy a [Parse-server](https://github.com/ParsePlatform/parse-server) -app to [Google App Engine](https://cloud.google.com/appengine) Node.js Standard -Environment and Flexible Environment. +app to [Google App Engine](https://cloud.google.com/appengine) Node.js [Standard +Environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). ## Setup diff --git a/appengine/pubsub/README.md b/appengine/pubsub/README.md index 7460908ca6..f6737e8abb 100644 --- a/appengine/pubsub/README.md +++ b/appengine/pubsub/README.md @@ -1,7 +1,8 @@ # Node.js Cloud Pub/Sub sample for Google App Engine This sample shows how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine](https://cloud.google.com/appengine) -Standard Environment and Flexible Environment using Node.js. +[Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). ## Setup diff --git a/appengine/redis/README.md b/appengine/redis/README.md index 1e085c2c05..152df1f58d 100644 --- a/appengine/redis/README.md +++ b/appengine/redis/README.md @@ -6,12 +6,13 @@ used as database, cache and message broker. Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -App Engine Node.js Flexible Environment users may also read the community -tutorial [Redis on App Engine Tutorial][2] for how to run and deploy this sample +[App Engine Node.js Flexible Environment][2] users may also read the community +tutorial [Redis on App Engine Tutorial][3] for how to run and deploy this sample app. -Additonally, read the [node_redis documentation][3]. +Additionally, you can also read the [node_redis documentation][4]. [1]: http://redis.io/ -[2]: https://cloud.google.com/nodejs/resources/databases/redis -[3]: https://github.com/NodeRedis/node_redis +[2]: https://cloud.google.com/appengine/docs/flexible/nodejs +[3]: https://cloud.google.com/nodejs/resources/databases/redis +[4]: https://github.com/NodeRedis/node_redis diff --git a/appengine/sendgrid/README.md b/appengine/sendgrid/README.md index 123fe4d2bb..2bebb12be2 100644 --- a/appengine/sendgrid/README.md +++ b/appengine/sendgrid/README.md @@ -1,8 +1,8 @@ # Node.js SendGrid email sample for Google App Engine This sample application shows how to use [SendGrid](https://www.sendgrid.com) on -[Google App Engine](https://cloud.google.com/appengine) Node.js Standard -Environment and Flexible Environment. +[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). For more information about SendGrid, see their [documentation](https://sendgrid.com/docs/User_Guide/index.html). diff --git a/appengine/sendgrid/app.flexible.yaml b/appengine/sendgrid/app.flexible.yaml index 8582bd77d5..79b79795bb 100644 --- a/appengine/sendgrid/app.flexible.yaml +++ b/appengine/sendgrid/app.flexible.yaml @@ -16,6 +16,9 @@ runtime: nodejs env: flex # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your Sendgrid account. Do not add this file to your source +# control. env_variables: SENDGRID_API_KEY: SENDGRID_SENDER: diff --git a/appengine/sendgrid/app.standard.yaml b/appengine/sendgrid/app.standard.yaml index cab1abd315..6feded5bf8 100644 --- a/appengine/sendgrid/app.standard.yaml +++ b/appengine/sendgrid/app.standard.yaml @@ -15,6 +15,9 @@ runtime: nodejs8 # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your Sendgrid account. Do not add this file to your source +# control. env_variables: SENDGRID_API_KEY: SENDGRID_SENDER: diff --git a/appengine/static-files/README.md b/appengine/static-files/README.md index cd1d9c8dd9..3a271fc414 100644 --- a/appengine/static-files/README.md +++ b/appengine/static-files/README.md @@ -1,6 +1,7 @@ # Serving static files in Node.js sample for Google App Engine -This sample demonstrates serving static files in a Node.js app for [Google App Engine](https://cloud.google.com/appengine) Node.js Standard Environment and Flexible Environment. +This sample demonstrates serving static files in a Node.js app for [Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs) ## Running locally diff --git a/appengine/twilio/README.md b/appengine/twilio/README.md index eeccdd9ce2..fa9f9c20d0 100644 --- a/appengine/twilio/README.md +++ b/appengine/twilio/README.md @@ -1,8 +1,8 @@ # Node.js Twilio voice and SMS sample for Google App Engine This sample shows how to use [Twilio](https://www.twilio.com) on -[Google App Engine](https://cloud.google.com/appengine) Node.js Standard -Environment and Flexible Environment. +[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs) For more information about Twilio, see the [Twilio Node library](https://www.twilio.com/docs/node/install). diff --git a/appengine/twilio/app.flexible.yaml b/appengine/twilio/app.flexible.yaml index 4de44bd625..a981d75ddd 100644 --- a/appengine/twilio/app.flexible.yaml +++ b/appengine/twilio/app.flexible.yaml @@ -16,6 +16,9 @@ runtime: nodejs env: flex # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your Twilio account. Do not add this file to your source +# control. env_variables: TWILIO_ACCOUNT_SID: TWILIO_AUTH_TOKEN: diff --git a/appengine/twilio/app.standard.yaml b/appengine/twilio/app.standard.yaml index a77f52a426..85fe77ab80 100644 --- a/appengine/twilio/app.standard.yaml +++ b/appengine/twilio/app.standard.yaml @@ -15,6 +15,9 @@ runtime: nodejs8 # [START env_variables] +# The following env variables may contain sensitive information that grants +# anyone access to your Twilio account. Do not add this file to your source +# control. env_variables: TWILIO_ACCOUNT_SID: TWILIO_AUTH_TOKEN: From 79fca649836ad3dbaf62342433185ba4bba5b885 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Mon, 2 Apr 2018 14:49:41 -0700 Subject: [PATCH 4/6] More minor fixes --- appengine/analytics/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/appengine/analytics/README.md b/appengine/analytics/README.md index 45d03dd3eb..6513d83f6a 100644 --- a/appengine/analytics/README.md +++ b/appengine/analytics/README.md @@ -42,11 +42,15 @@ or with `yarn`: ## Deploying to App Engine Standard Environment - gcloud app deploy app.standard.yaml +``` +gcloud app deploy app.standard.yaml +``` ## Deploying to App Engine Flexible Environment - gcloud app deploy app.flexible.yaml +``` +gcloud app deploy app.flexible.yaml +``` ## Running the tests From c0de187d405d76e9e8f87af84c72ab8ae3079da7 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Wed, 4 Apr 2018 11:35:30 -0700 Subject: [PATCH 5/6] Lint --- appengine/building-an-app/update/test/server.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine/building-an-app/update/test/server.test.js b/appengine/building-an-app/update/test/server.test.js index 8bfac5b946..c624b4c4b6 100755 --- a/appengine/building-an-app/update/test/server.test.js +++ b/appengine/building-an-app/update/test/server.test.js @@ -40,7 +40,7 @@ test.cb.serial(`should display form`, (t) => { .get(`/submit`) .expect(200) .expect((response) => { - t.true(response.text.includes('textarea name="message" placeholder="Message"'); + t.true(response.text.includes('textarea name="message" placeholder="Message"')); }) .end(t.end); }); From 787fd0b1e87116c707a139533259458161428fd1 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Tue, 10 Apr 2018 15:54:17 -0700 Subject: [PATCH 6/6] Applied requested changes --- appengine/README.md | 8 ++--- appengine/analytics/README.md | 8 ++--- appengine/building-an-app/build/README.md | 2 +- appengine/building-an-app/build/package.json | 14 +++++++- .../building-an-app/build/test/server.test.js | 36 ------------------- appengine/building-an-app/update/README.md | 2 +- appengine/cloudsql/README.md | 4 +-- appengine/cloudsql_postgresql/README.md | 6 ++-- appengine/cloudtasks/README.md | 14 ++++---- appengine/datastore/README.md | 8 ++--- appengine/endpoints/README.md | 5 +-- appengine/errorreporting/README.md | 2 +- appengine/hello-world/flexible/README.md | 6 ++-- appengine/hello-world/standard/README.md | 6 ++-- appengine/loopback/README.md | 2 +- appengine/mailjet/README.md | 2 +- appengine/memcached/README.md | 4 +-- appengine/mongodb/README.md | 2 +- appengine/parse-server/README.md | 10 +++--- appengine/pubsub/README.md | 4 +-- appengine/redis/README.md | 2 +- appengine/restify/README.md | 3 +- appengine/sendgrid/README.md | 8 ++--- appengine/sendgrid/app.js | 3 +- appengine/static-files/README.md | 4 +-- appengine/storage/flexible/README.md | 2 +- appengine/storage/standard/README.md | 2 +- appengine/twilio/README.md | 4 +-- 28 files changed, 75 insertions(+), 98 deletions(-) delete mode 100755 appengine/building-an-app/build/test/server.test.js diff --git a/appengine/README.md b/appengine/README.md index 379875f429..b63051b1a0 100644 --- a/appengine/README.md +++ b/appengine/README.md @@ -60,10 +60,10 @@ The App Engine Node.js samples typically that you do the following: Some samples may have special deployment instructions. Refer to the `README.md` file in the sample folder. -Many samples in this folder can be deployed to both App Engine Node.js Standard -Environment and Flexible Environment. Those samples come with two different -App Engine configuration files: `app.flexible.yaml` for Flexible Environment, -and `app.standard.yaml` for Standard Environment. +Many samples in this folder can be deployed to both App Engine Node.js standard +environment and flexible environment. Those samples come with two different +App Engine configuration files: `app.flexible.yaml` for flexible environment, +and `app.standard.yaml` for standard environment. Samples with one single configuration file, `app.yaml`, can only be deployed to one of the two environments. See the `README.md` files for these samples diff --git a/appengine/analytics/README.md b/appengine/analytics/README.md index 6513d83f6a..2afa56a3fd 100644 --- a/appengine/analytics/README.md +++ b/appengine/analytics/README.md @@ -3,9 +3,9 @@ This sample application shows how to integrate your Node.js application with Google Analytics on Google App Engine. -[App Engine Standard][appengine-std] users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app. +[App Engine standard environment][appengine-std] users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app. -[App Engine Flexible][appengine-flex] users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app. +[App Engine flexible environment][appengine-flex] users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -40,13 +40,13 @@ or with `yarn`: GA_TRACKING_ID=YOUR_TRACKING_ID yarn start -## Deploying to App Engine Standard Environment +## Deploying to App Engine standard Environment ``` gcloud app deploy app.standard.yaml ``` -## Deploying to App Engine Flexible Environment +## Deploying to App Engine flexible Environment ``` gcloud app deploy app.flexible.yaml diff --git a/appengine/building-an-app/build/README.md b/appengine/building-an-app/build/README.md index 84eef32ad9..c5afa706fd 100644 --- a/appengine/building-an-app/build/README.md +++ b/appengine/building-an-app/build/README.md @@ -2,7 +2,7 @@ This is the sample application for the [Writing Your Web Service with Node.js][tutorial] -tutorial found in the [Google App Engine Node.js Standard Environment][appengine] +tutorial found in the [Google App Engine Node.js standard environment][appengine] documentation. * [Setup](#setup) diff --git a/appengine/building-an-app/build/package.json b/appengine/building-an-app/build/package.json index 8206285234..b79b11d691 100755 --- a/appengine/building-an-app/build/package.json +++ b/appengine/building-an-app/build/package.json @@ -9,7 +9,7 @@ "deploy": "gcloud app deploy", "lint": "samples lint", "pretest": "npm run lint", - "test": "ava --verbose test/*.test.js" + "test": "samples test app" }, "repository": { "type": "git", @@ -27,5 +27,17 @@ "@google-cloud/nodejs-repo-tools": "1.4.17", "ava": "0.22.0", "semistandard": "^12.0.1" + }, + "cloud-repo-tools": { + "requiresKeyFile": false, + "requiresProjectId": false, + "test": { + "app": { + "args": [ + "server.js" + ], + "msg": "Hello from App Engine!" + } + } } } diff --git a/appengine/building-an-app/build/test/server.test.js b/appengine/building-an-app/build/test/server.test.js deleted file mode 100755 index 45323f68fe..0000000000 --- a/appengine/building-an-app/build/test/server.test.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018, 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'; - -const path = require(`path`); -const test = require(`ava`); -const utils = require(`@google-cloud/nodejs-repo-tools`); - -const cwd = path.join(__dirname, `../`); -const requestObj = utils.getRequest({ - cwd: cwd, - cmd: `server` }); - -test.beforeEach(utils.stubConsole); -test.afterEach.always(utils.restoreConsole); - -test.cb.serial(`should send greetings`, (t) => { - requestObj - .get(`/`) - .expect(200) - .expect((response) => { - t.is(response.text, `Hello from App Engine!`); - }) - .end(t.end); -}); diff --git a/appengine/building-an-app/update/README.md b/appengine/building-an-app/update/README.md index f8a7cc992d..63ee9d563b 100644 --- a/appengine/building-an-app/update/README.md +++ b/appengine/building-an-app/update/README.md @@ -2,7 +2,7 @@ This is the sample application for the [Updating Your Web Service][tutorial] -tutorial found in the [Google App Engine Node.js Standard Environment][appengine] +tutorial found in the [Google App Engine Node.js standard environment][appengine] documentation. * [Setup](#setup) diff --git a/appengine/cloudsql/README.md b/appengine/cloudsql/README.md index 11bb95fcc3..ce3f598446 100644 --- a/appengine/cloudsql/README.md +++ b/appengine/cloudsql/README.md @@ -3,9 +3,9 @@ This sample application shows how to use [Google Cloud SQL[[sql] for [MySQL][mysql] on Google App Engine. -[App Engine Standard][appengine-std] users: See tutorial [Using Cloud SQL for MySQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. +[App Engine standard environment][appengine-std] users: See tutorial [Using Cloud SQL for MySQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. -[App Engine Flexible][appengine-flex] users: See tutorial [Using Cloud SQL for MySQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. +[App Engine flexible environment][appengine-flex] users: See tutorial [Using Cloud SQL for MySQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ [mysql]: https://www.mysql.com/downloads/ diff --git a/appengine/cloudsql_postgresql/README.md b/appengine/cloudsql_postgresql/README.md index 7e7d63ce12..9ca57720aa 100644 --- a/appengine/cloudsql_postgresql/README.md +++ b/appengine/cloudsql_postgresql/README.md @@ -1,12 +1,12 @@ -# Cloud SQL for PostgresSQL Node.js sample on App Engine flexible environment +# Cloud SQL for PostgreSQL Node.js sample on App Engine flexible environment This sample application shows how to use [Google Cloud SQL[[sql] for [PostgreSQL][postgres] on Google App Engine. -[App Engine Standard][appengine-std] users: See tutorial [ +[App Engine standard environment][appengine-std] users: See tutorial [ Using Cloud SQL for PostgreSQL (App Engine Standard Environment)][std-tutorial] for more information on running and deploying this app. -[App Engine Flexible][appengine-flex] users: See tutorial [ +[App Engine flexible environment][appengine-flex] users: See tutorial [ Using Cloud SQL for PostgreSQL (App Engine Flexible Environment)][flex-tutorial] for more information on running and deploying this app. [sql]: https://cloud.google.com/sql/ diff --git a/appengine/cloudtasks/README.md b/appengine/cloudtasks/README.md index 98e00a86e5..74f476ba23 100644 --- a/appengine/cloudtasks/README.md +++ b/appengine/cloudtasks/README.md @@ -1,7 +1,7 @@ # Node.js Google Cloud Tasks sample for Google App Engine This sample application shows how to use [Google Cloud Tasks](https://cloud.google.com/cloud-tasks/) -on Google App Engine Node.js [Standard Environment][appengine-std] and [Flexible Environment][appengine-flex]. +on Google App Engine Node.js [standard environment][appengine-std] and [flexible environment][appengine-flex]. App Engine queues push tasks to an App Engine HTTP target. This directory contains both the App Engine app to deploy, as well as the snippets to run @@ -13,11 +13,11 @@ the App Engine app. `server.js` is the main App Engine app. This app serves as an endpoint to receive App Engine task attempts. -`app.standard.yaml` configures the app for App Engine Node.js Standard -Environment. +`app.standard.yaml` configures the app for App Engine Node.js standard +environment. -`app.flexible.yaml` configures the app for App Engine Node.js Flexible -Environment. +`app.flexible.yaml` configures the app for App Engine Node.js flexible +environment. * [Setup](#setup) * [Running locally](#running-locally) @@ -52,7 +52,7 @@ version unless configured to do otherwise. Read the online help for the `create-app-engine-queue` or the `update-app-engine-queue` commands to learn about routing overrides for App Engine queues. -## Deploying the app to App Engine Standard Environment +## Deploying the app to App Engine standard environment Deploy the App Engine app with gcloud: @@ -68,7 +68,7 @@ HTTP POST request and logs it. The log output can be viewed with: gcloud app logs read -## Deploying the app to App Engine Flexible Environment +## Deploying the app to App Engine flexible environment Deploy the App Engine app with gcloud: diff --git a/appengine/datastore/README.md b/appengine/datastore/README.md index 3796d24d53..c775a53cdf 100644 --- a/appengine/datastore/README.md +++ b/appengine/datastore/README.md @@ -3,9 +3,9 @@ This sample application shows how to use Google Cloud Datastore on Google App Engine. -[App Engine Standard][appengine-std] users: See tutorial [Using Cloud Datastore][tutorial-std] for more information on running and deploying this app. +[App Engine standard environment][appengine-std] users: See tutorial [Using Cloud Datastore][tutorial-std] for more information on running and deploying this app. -[App Engine Flexible][appengine-flex] users: See tutorial [Using Cloud Datastore][tutorial-flex] for more information on running and deploying this app. +[App Engine flexible environment][appengine-flex] users: See tutorial [Using Cloud Datastore][tutorial-flex] for more information on running and deploying this app. * [Setup](#setup) * [Running locally](#running-locally) @@ -38,11 +38,11 @@ or with `yarn`: yarn start -## Deploying to App Engine Standard Environment +## Deploying to App Engine standard environment gcloud app deploy app.standard.yaml -## Deploying to App Engine Flexible Environment +## Deploying to App Engine flexible environment gcloud app deploy app.flexible.yaml diff --git a/appengine/endpoints/README.md b/appengine/endpoints/README.md index 5d2355d5a1..14724e3271 100644 --- a/appengine/endpoints/README.md +++ b/appengine/endpoints/README.md @@ -1,6 +1,7 @@ -# Google Cloud Endpoints sample for Google App Engine Flexible Environment +# Google Cloud Endpoints sample for Google App Engine flexible environment -This sample demonstrates how to use Google Cloud Endpoints on Google App Engine Flexible Environment using Node.js. +This sample demonstrates how to use Google Cloud Endpoints on Google App Engine +flexible environment using Node.js. ## Running locally diff --git a/appengine/errorreporting/README.md b/appengine/errorreporting/README.md index acd756f52c..ff850097dd 100644 --- a/appengine/errorreporting/README.md +++ b/appengine/errorreporting/README.md @@ -1,7 +1,7 @@ # Node.js error reporting sample for Google App Engine This sample shows how to use Stackdriver Error Reporting on Google App Engine -Node.js [Standard Environment][appengine-std] and [Flexible Environment][appengine-flex]. +Node.js [standard environment][appengine-std] and [flexible environment][appengine-flex]. ## Running locally diff --git a/appengine/hello-world/flexible/README.md b/appengine/hello-world/flexible/README.md index 246ed92a5a..585ccade53 100644 --- a/appengine/hello-world/flexible/README.md +++ b/appengine/hello-world/flexible/README.md @@ -1,8 +1,8 @@ -# Quickstart for Node.js in the App Engine Flexible Environment +# Quickstart for Node.js in the App Engine flexible environment This is the sample application for the -[Quickstart for Node.js in the App Engine Flexible Environment][tutorial] -tutorial found in the [Google App Engine Node.js Flexible Environment][appengine] +[Quickstart for Node.js in the App Engine flexible environment][tutorial] +tutorial found in the [Google App Engine Node.js flexible environment][appengine] documentation. * [Setup](#setup) diff --git a/appengine/hello-world/standard/README.md b/appengine/hello-world/standard/README.md index afc2f09bf0..49a651de0e 100644 --- a/appengine/hello-world/standard/README.md +++ b/appengine/hello-world/standard/README.md @@ -1,8 +1,8 @@ -# Quickstart for Node.js in the App Engine Standard Environment +# Quickstart for Node.js in the App Engine standard environment This is the sample application for the -[Quickstart for Node.js in the App Engine Standard Environment][tutorial] -tutorial found in the [Google App Engine Node.js Flexible Environment][appengine] +[Quickstart for Node.js in the App Engine standard environment][tutorial] +tutorial found in the [Google App Engine Node.js standard environment][appengine] documentation. * [Setup](#setup) diff --git a/appengine/loopback/README.md b/appengine/loopback/README.md index 3385180ad8..c8ec714155 100644 --- a/appengine/loopback/README.md +++ b/appengine/loopback/README.md @@ -5,7 +5,7 @@ Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -[App Engine Flexible][5] users may also read the community +[App Engine flexible environment][5] users may also read the community tutorial [Loopback.js on App Engine Tutorial][2] for how to run and deploy this sample app. diff --git a/appengine/mailjet/README.md b/appengine/mailjet/README.md index df1c610959..38e1183f06 100644 --- a/appengine/mailjet/README.md +++ b/appengine/mailjet/README.md @@ -6,7 +6,7 @@ This sample application demonstrates how to use [Express.js][2] and [node-mailjet][3] to send transactional email on [Google App Engine][4] Node.js -[Standard Environment][5] and [Flexible Environment][6]. +[standard environment][5] and [flexible environment][6]. You can also read the [Mailjet documentation][7]. diff --git a/appengine/memcached/README.md b/appengine/memcached/README.md index 440ea7ebbd..5aec146d19 100644 --- a/appengine/memcached/README.md +++ b/appengine/memcached/README.md @@ -1,8 +1,8 @@ # Memcached sample for Google App Engine This sample demonstrates accessing Memcached from Node.js on -[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard -Environment][appengine-std] and [Flexible Environment][appengine-flex]. +[Google App Engine](https://cloud.google.com/appengine) Node.js [standard +environment][appengine-std] and [flexible environment][appengine-flex]. ## Running locally diff --git a/appengine/mongodb/README.md b/appengine/mongodb/README.md index 29e107948e..b66d3c1463 100644 --- a/appengine/mongodb/README.md +++ b/appengine/mongodb/README.md @@ -5,7 +5,7 @@ Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -[App Engine Node.js Flexible Environment][2] users may also read the community +[App Engine Node.js flexible environment][2] users may also read the community tutorial [MongoDB on App Engine Tutorial][3] for how to run and deploy this sample app. diff --git a/appengine/parse-server/README.md b/appengine/parse-server/README.md index e78d8d80b7..93bb4279be 100644 --- a/appengine/parse-server/README.md +++ b/appengine/parse-server/README.md @@ -1,9 +1,9 @@ # Parse-server sample for Google App Engine This sample shows how to deploy a [Parse-server](https://github.com/ParsePlatform/parse-server) -app to [Google App Engine](https://cloud.google.com/appengine) Node.js [Standard -Environment](https://cloud.google.com/appengine/docs/standard/nodejs) -and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). +app to [Google App Engine](https://cloud.google.com/appengine) Node.js [standard +environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [flexible environment](https://cloud.google.com/appengine/docs/flexible/nodejs). ## Setup @@ -25,12 +25,12 @@ and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/node 1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). 1. `npm start` -## Deploy to App Engine Standard Environment +## Deploy to App Engine standard environment 1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). 1. `gcloud app deploy app.standard.yaml` -## Deploy to App Engine Flexible Environment +## Deploy to App Engine flexible environment 1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json). 1. `gcloud app deploy app.flexible.yaml` diff --git a/appengine/pubsub/README.md b/appengine/pubsub/README.md index f6737e8abb..1fa95d2077 100644 --- a/appengine/pubsub/README.md +++ b/appengine/pubsub/README.md @@ -1,8 +1,8 @@ # Node.js Cloud Pub/Sub sample for Google App Engine This sample shows how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine](https://cloud.google.com/appengine) -[Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) -and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). +[standard environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [flexible environment](https://cloud.google.com/appengine/docs/flexible/nodejs). ## Setup diff --git a/appengine/redis/README.md b/appengine/redis/README.md index 152df1f58d..81231b23ed 100644 --- a/appengine/redis/README.md +++ b/appengine/redis/README.md @@ -6,7 +6,7 @@ used as database, cache and message broker. Refer to the [appengine/README.md](../README.md) file for more instructions on running and deploying this app. -[App Engine Node.js Flexible Environment][2] users may also read the community +[App Engine Node.js flexible environment][2] users may also read the community tutorial [Redis on App Engine Tutorial][3] for how to run and deploy this sample app. diff --git a/appengine/restify/README.md b/appengine/restify/README.md index 9ee0cc4dc1..f51a5a7e48 100644 --- a/appengine/restify/README.md +++ b/appengine/restify/README.md @@ -1,2 +1 @@ -This has moved to [EDIT ON GITHUB REPORT ISSUE PAGE HISTORY -Run Restify.js on Google App Engine Flexible Environment](https://cloud.google.com/community/tutorials/run-restifyjs-on-google-app-engine). +This has moved to [Run Restify.js on Google App Engine Flexible Environment](https://cloud.google.com/community/tutorials/run-restifyjs-on-google-app-engine). diff --git a/appengine/sendgrid/README.md b/appengine/sendgrid/README.md index 2bebb12be2..89fcdd7e15 100644 --- a/appengine/sendgrid/README.md +++ b/appengine/sendgrid/README.md @@ -1,8 +1,8 @@ # Node.js SendGrid email sample for Google App Engine This sample application shows how to use [SendGrid](https://www.sendgrid.com) on -[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) -and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs). +[Google App Engine](https://cloud.google.com/appengine) Node.js [standard environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [flexible environment](https://cloud.google.com/appengine/docs/flexible/nodejs). For more information about SendGrid, see their [documentation](https://sendgrid.com/docs/User_Guide/index.html). @@ -18,8 +18,8 @@ Before you can run or deploy the sample, you will need to do the following: 1. [Create a SendGrid Account](http://sendgrid.com/partner/google). As of September 2015, Google users start with 25,000 free emails per month. 1. Configure your SendGrid settings in the environment variables section in -`app.standard.yaml` (if you are deploying to App Engine Standard Environment) or -`app.flexible.yaml` (if you are deploying to App Engine Flexible Environment). +`app.standard.yaml` (if you are deploying to App Engine standard environment) or +`app.flexible.yaml` (if you are deploying to App Engine flexible environment). ## Running locally diff --git a/appengine/sendgrid/app.js b/appengine/sendgrid/app.js index 0d48223e10..3eb5753fcf 100644 --- a/appengine/sendgrid/app.js +++ b/appengine/sendgrid/app.js @@ -21,7 +21,8 @@ const path = require('path'); const bodyParser = require('body-parser'); // [START setup] -// The following environment variables are set by app.yaml when running on GAE, +// The following environment variables are set by app.yaml (app.flexible.yaml or +// app.standard.yaml) when running on Google App Engine, // but will need to be manually set when running locally. const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY; const SENDGRID_SENDER = process.env.SENDGRID_SENDER; diff --git a/appengine/static-files/README.md b/appengine/static-files/README.md index 3a271fc414..a76dad39ce 100644 --- a/appengine/static-files/README.md +++ b/appengine/static-files/README.md @@ -1,7 +1,7 @@ # Serving static files in Node.js sample for Google App Engine -This sample demonstrates serving static files in a Node.js app for [Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) -and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs) +This sample demonstrates serving static files in a Node.js app for [Google App Engine](https://cloud.google.com/appengine) Node.js [standard environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [flexible environment](https://cloud.google.com/appengine/docs/flexible/nodejs) ## Running locally diff --git a/appengine/storage/flexible/README.md b/appengine/storage/flexible/README.md index aafe8ceff7..de65b02ee3 100644 --- a/appengine/storage/flexible/README.md +++ b/appengine/storage/flexible/README.md @@ -1,7 +1,7 @@ # Node.js Google Cloud Storage sample for Google App Engine This sample demonstrates how to use [Google Cloud Storage](https://cloud.google.com/storage/) -on [Google App Engine Flexible Environment](https://cloud.google.com/appengine). +on [Google App Engine flexible environment](https://cloud.google.com/appengine). ## Setup diff --git a/appengine/storage/standard/README.md b/appengine/storage/standard/README.md index 8207245a02..317a118453 100644 --- a/appengine/storage/standard/README.md +++ b/appengine/storage/standard/README.md @@ -1,7 +1,7 @@ # Node.js Google Cloud Storage sample for Google App Engine This sample demonstrates how to use [Google Cloud Storage](https://cloud.google.com/storage/) -on [Google App Engine Standard Environment](https://cloud.google.com/appengine). +on [Google App Engine standard environment](https://cloud.google.com/appengine). ## Setup diff --git a/appengine/twilio/README.md b/appengine/twilio/README.md index fa9f9c20d0..40bdb371e2 100644 --- a/appengine/twilio/README.md +++ b/appengine/twilio/README.md @@ -1,8 +1,8 @@ # Node.js Twilio voice and SMS sample for Google App Engine This sample shows how to use [Twilio](https://www.twilio.com) on -[Google App Engine](https://cloud.google.com/appengine) Node.js [Standard Environment](https://cloud.google.com/appengine/docs/standard/nodejs) -and [Flexible Environment](https://cloud.google.com/appengine/docs/flexible/nodejs) +[Google App Engine](https://cloud.google.com/appengine) Node.js [standard environment](https://cloud.google.com/appengine/docs/standard/nodejs) +and [flexible environment](https://cloud.google.com/appengine/docs/flexible/nodejs) For more information about Twilio, see the [Twilio Node library](https://www.twilio.com/docs/node/install).