From 2581b47b9f1004686a9e178001099813a26162ba Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 20 Aug 2018 13:22:54 -0700 Subject: [PATCH] update region tags (#709) * request example * analytics * quickstart * memcache, redis * mailjet, sendgrid * static files * cloud sql and postgresql and datastore * Storage, twilio * pubsub * fix replace all errors --- appengine/analytics/app.flexible.yaml | 6 ++---- appengine/analytics/app.js | 4 ++-- appengine/analytics/app.standard.yaml | 6 ++---- appengine/cloudsql/app.flexible.yaml | 8 ++------ appengine/cloudsql/app.standard.yaml | 8 ++------ appengine/cloudsql/createTables.js | 4 ++-- appengine/cloudsql/server.js | 8 ++++---- appengine/cloudsql_postgresql/app.flexible.yaml | 8 ++------ appengine/cloudsql_postgresql/app.standard.yaml | 8 ++------ appengine/cloudsql_postgresql/createTables.js | 4 ++-- appengine/cloudsql_postgresql/server.js | 8 ++++---- appengine/datastore/app.flexible.yaml | 2 -- appengine/datastore/app.js | 12 ++---------- appengine/datastore/app.standard.yaml | 2 -- appengine/hello-world/flexible/app.js | 4 ++-- appengine/hello-world/flexible/app.yaml | 6 +++--- appengine/hello-world/standard/app.js | 4 ++-- appengine/mailjet/app.flexible.yaml | 4 ++-- appengine/mailjet/app.js | 12 ++++-------- appengine/mailjet/app.standard.yaml | 4 ++-- appengine/memcached/app.flexible.yaml | 6 ++---- appengine/memcached/app.js | 8 ++------ appengine/memcached/app.standard.yaml | 6 ++---- appengine/pubsub/app.flexible.yaml | 6 ++---- appengine/pubsub/app.js | 10 ++++------ appengine/pubsub/app.standard.yaml | 8 ++------ appengine/pubsub/views/index.pug | 2 -- appengine/redis/server.js | 4 ++-- appengine/sendgrid/app.flexible.yaml | 6 ++---- appengine/sendgrid/app.js | 12 ++---------- appengine/sendgrid/app.standard.yaml | 6 ++---- appengine/static-files/app.flexible.yaml | 2 -- appengine/static-files/app.js | 4 ++-- appengine/static-files/app.standard.yaml | 2 -- appengine/static-files/public/main.css | 4 ++-- appengine/storage/flexible/app.js | 10 ++-------- appengine/storage/flexible/app.yaml | 6 ++---- appengine/storage/standard/app.js | 10 ++-------- appengine/storage/standard/app.yaml | 6 ++---- appengine/twilio/app.flexible.yaml | 6 ++---- appengine/twilio/app.js | 16 ++++++---------- appengine/twilio/app.standard.yaml | 6 ++---- 42 files changed, 87 insertions(+), 181 deletions(-) diff --git a/appengine/analytics/app.flexible.yaml b/appengine/analytics/app.flexible.yaml index 7568e280fb..9d3c4ec000 100644 --- a/appengine/analytics/app.flexible.yaml +++ b/appengine/analytics/app.flexible.yaml @@ -11,12 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env] +# [START gae_flex_analytics_env_variables] env_variables: GA_TRACKING_ID: YOUR_TRACKING_ID -# [END env] -# [END app_yaml] +# [END gae_flex_analytics_env_variables] diff --git a/appengine/analytics/app.js b/appengine/analytics/app.js index 2194d9b6e6..42ee599913 100644 --- a/appengine/analytics/app.js +++ b/appengine/analytics/app.js @@ -15,7 +15,7 @@ 'use strict'; -// [START app] +// [START gae_flex_analytics_track_event] const express = require('express'); const got = require('got'); @@ -69,4 +69,4 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_flex_analytics_track_event] diff --git a/appengine/analytics/app.standard.yaml b/appengine/analytics/app.standard.yaml index 5746c3569b..9105c53d7e 100644 --- a/appengine/analytics/app.standard.yaml +++ b/appengine/analytics/app.standard.yaml @@ -11,11 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env] +# [START gae_analytics_env_variables] env_variables: GA_TRACKING_ID: YOUR_TRACKING_ID -# [END env] -# [END app_yaml] +# [END gae_analytics_env_variables] diff --git a/appengine/cloudsql/app.flexible.yaml b/appengine/cloudsql/app.flexible.yaml index dd69cea493..22bc5fbf61 100644 --- a/appengine/cloudsql/app.flexible.yaml +++ b/appengine/cloudsql/app.flexible.yaml @@ -11,11 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env] +# [START gae_flex_mysql_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: @@ -24,13 +23,10 @@ env_variables: 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] +# [END gae_flex_mysql_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/app.standard.yaml b/appengine/cloudsql/app.standard.yaml index 5608bdc126..62dfbbb386 100644 --- a/appengine/cloudsql/app.standard.yaml +++ b/appengine/cloudsql/app.standard.yaml @@ -11,10 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env] +# [START gae_mysql_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: @@ -23,13 +22,10 @@ env_variables: 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] +# [END gae_mysql_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/createTables.js b/appengine/cloudsql/createTables.js index a0643862d8..73a4c79ff1 100644 --- a/appengine/cloudsql/createTables.js +++ b/appengine/cloudsql/createTables.js @@ -15,7 +15,7 @@ 'use strict'; -// [START createTables] +// [START gae_flex_mysql_create_tables] const Knex = require('knex'); const prompt = require('prompt'); @@ -51,4 +51,4 @@ prompt.get(FIELDS, (err, config) => { } }); }); -// [END createTables] +// [END gae_flex_mysql_create_tables] diff --git a/appengine/cloudsql/server.js b/appengine/cloudsql/server.js index fc7e674beb..ed47a941c0 100644 --- a/appengine/cloudsql/server.js +++ b/appengine/cloudsql/server.js @@ -18,7 +18,7 @@ // Require process, so we can mock environment variables const process = require('process'); -// [START app] +// [START gae_flex_mysql_app] const express = require('express'); const Knex = require('knex'); const crypto = require('crypto'); @@ -29,7 +29,7 @@ app.enable('trust proxy'); const knex = connect(); function connect () { - // [START connect] + // [START gae_flex_mysql_connect] const config = { user: process.env.SQL_USER, password: process.env.SQL_PASSWORD, @@ -45,7 +45,7 @@ function connect () { client: 'mysql', connection: config }); - // [END connect] + // [END gae_flex_mysql_connect] return knex; } @@ -105,6 +105,6 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_flex_mysql_app] module.exports = app; diff --git a/appengine/cloudsql_postgresql/app.flexible.yaml b/appengine/cloudsql_postgresql/app.flexible.yaml index dd69cea493..3f8fcf0eec 100644 --- a/appengine/cloudsql_postgresql/app.flexible.yaml +++ b/appengine/cloudsql_postgresql/app.flexible.yaml @@ -11,11 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env] +# [START gae_flex_postgres_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: @@ -24,13 +23,10 @@ env_variables: 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] +# [END gae_flex_postgres_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/app.standard.yaml b/appengine/cloudsql_postgresql/app.standard.yaml index 5608bdc126..7f80395609 100644 --- a/appengine/cloudsql_postgresql/app.standard.yaml +++ b/appengine/cloudsql_postgresql/app.standard.yaml @@ -11,10 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env] +# [START gae_postgres_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: @@ -23,13 +22,10 @@ env_variables: 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] +# [END gae_postgres_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/createTables.js b/appengine/cloudsql_postgresql/createTables.js index c421f9d7ee..91dcc51dc7 100644 --- a/appengine/cloudsql_postgresql/createTables.js +++ b/appengine/cloudsql_postgresql/createTables.js @@ -15,7 +15,7 @@ 'use strict'; -// [START createTables] +// [START gae_flex_postgres_create_tables] const Knex = require('knex'); const prompt = require('prompt'); @@ -50,4 +50,4 @@ prompt.get(FIELDS, (err, config) => { } }); }); -// [END createTables] +// [END gae_flex_postgres_create_tables] diff --git a/appengine/cloudsql_postgresql/server.js b/appengine/cloudsql_postgresql/server.js index 1a2343d11f..5eb8bde275 100644 --- a/appengine/cloudsql_postgresql/server.js +++ b/appengine/cloudsql_postgresql/server.js @@ -18,7 +18,7 @@ // Require process, so we can mock environment variables const process = require('process'); -// [START app] +// [START gae_flex_postgres_app] const express = require('express'); const Knex = require('knex'); const crypto = require('crypto'); @@ -29,7 +29,7 @@ app.enable('trust proxy'); const knex = connect(); function connect () { - // [START connect] + // [START gae_flex_postgres_connect] const config = { user: process.env.SQL_USER, password: process.env.SQL_PASSWORD, @@ -45,7 +45,7 @@ function connect () { client: 'pg', connection: config }); - // [END connect] + // [END gae_flex_postgres_connect] return knex; } @@ -105,6 +105,6 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_flex_postgres_app] module.exports = app; diff --git a/appengine/datastore/app.flexible.yaml b/appengine/datastore/app.flexible.yaml index 5fee6617ab..f42cc4aea0 100644 --- a/appengine/datastore/app.flexible.yaml +++ b/appengine/datastore/app.flexible.yaml @@ -11,7 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [END app_yaml] diff --git a/appengine/datastore/app.js b/appengine/datastore/app.js index 4c28d110d4..7ebc61cf29 100644 --- a/appengine/datastore/app.js +++ b/appengine/datastore/app.js @@ -13,10 +13,9 @@ * limitations under the License. */ -// [START app] +// [START gae_flex_datastore_app] 'use strict'; -// [START setup] const express = require('express'); const crypto = require('crypto'); @@ -32,9 +31,7 @@ const Datastore = require('@google-cloud/datastore'); // Instantiate a datastore client const datastore = Datastore(); -// [END setup] -// [START insertVisit] /** * Insert a visit record into the database. * @@ -46,9 +43,7 @@ function insertVisit (visit) { data: visit }); } -// [END insertVisit] -// [START getVisits] /** * Retrieve the latest 10 visit records from the database. */ @@ -63,7 +58,6 @@ function getVisits () { return entities.map((entity) => `Time: ${entity.timestamp}, AddrHash: ${entity.userIp}`); }); } -// [END getVisits] app.get('/', (req, res, next) => { // Create a visit record to be stored in the database @@ -86,13 +80,11 @@ app.get('/', (req, res, next) => { .catch(next); }); -// [START listen] const PORT = process.env.PORT || 8080; app.listen(process.env.PORT || 8080, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END listen] -// [END app] +// [END gae_flex_datastore_app] module.exports = app; diff --git a/appengine/datastore/app.standard.yaml b/appengine/datastore/app.standard.yaml index 8f8f6fd97a..9442de7de0 100644 --- a/appengine/datastore/app.standard.yaml +++ b/appengine/datastore/app.standard.yaml @@ -11,6 +11,4 @@ # 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/flexible/app.js b/appengine/hello-world/flexible/app.js index be1e3735bc..d6c60726c8 100644 --- a/appengine/hello-world/flexible/app.js +++ b/appengine/hello-world/flexible/app.js @@ -15,7 +15,7 @@ 'use strict'; -// [START app] +// [START gae_flex_quickstart] const express = require('express'); const app = express(); @@ -30,4 +30,4 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_flex_quickstart] diff --git a/appengine/hello-world/flexible/app.yaml b/appengine/hello-world/flexible/app.yaml index 9d11ec86b7..0fd3991ca9 100644 --- a/appengine/hello-world/flexible/app.yaml +++ b/appengine/hello-world/flexible/app.yaml @@ -11,11 +11,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] +# [START gae_flex_quickstart_yaml] runtime: nodejs env: flex -# This sample incurs costs to run on the App Engine flexible environment. +# This sample incurs costs to run on the App Engine flexible environment. # The settings below are to reduce costs during testing and are not appropriate # for production use. For more information, see: # https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml @@ -26,4 +26,4 @@ resources: memory_gb: 0.5 disk_size_gb: 10 -# [END app_yaml] +# [END gae_flex_quickstart_yaml] diff --git a/appengine/hello-world/standard/app.js b/appengine/hello-world/standard/app.js index be1e3735bc..7a09308358 100644 --- a/appengine/hello-world/standard/app.js +++ b/appengine/hello-world/standard/app.js @@ -15,7 +15,7 @@ 'use strict'; -// [START app] +// [START gae_node_request_example] const express = require('express'); const app = express(); @@ -30,4 +30,4 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_node_request_example] diff --git a/appengine/mailjet/app.flexible.yaml b/appengine/mailjet/app.flexible.yaml index b0e77702c2..82ef6c5be0 100644 --- a/appengine/mailjet/app.flexible.yaml +++ b/appengine/mailjet/app.flexible.yaml @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] +# [START gae_flex_mailjet_yaml] runtime: nodejs env: flex @@ -21,4 +21,4 @@ env: flex env_variables: MJ_APIKEY_PUBLIC: MJ_APIKEY_PRIVATE: -# [END app_yaml] +# [END gae_flex_mailjet_yaml] diff --git a/appengine/mailjet/app.js b/appengine/mailjet/app.js index f2626d76dd..76da21f9da 100644 --- a/appengine/mailjet/app.js +++ b/appengine/mailjet/app.js @@ -19,12 +19,12 @@ var express = require('express'); var path = require('path'); var bodyParser = require('body-parser'); -// [START setup] +// [START gae_flex_mailjet_config] var Mailjet = require('node-mailjet').connect( process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE ); -// [END setup] +// [END gae_flex_mailjet_config] var app = express(); @@ -36,13 +36,11 @@ app.set('view engine', 'jade'); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); -// [START index] app.get('/', function (req, res) { res.render('index'); }); -// [END index] -// [START hello] +// [START gae_flex_mailjet_send_message] app.post('/hello', function (req, res, next) { var options = { 'Messages': [ @@ -77,11 +75,9 @@ app.post('/hello', function (req, res, next) { return next(err); }); }); -// [END hello] +// [END gae_flex_mailjet_send_message] -// [START server] var server = app.listen(process.env.PORT || 8080, function () { console.log('App listening on port %s', server.address().port); console.log('Press Ctrl+C to quit.'); }); -// [END server] diff --git a/appengine/mailjet/app.standard.yaml b/appengine/mailjet/app.standard.yaml index 4c7e57e5b4..dc4f8dc76b 100644 --- a/appengine/mailjet/app.standard.yaml +++ b/appengine/mailjet/app.standard.yaml @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] +# [START gae_mailjet_yaml] runtime: nodejs8 # The following env variables may contain sensitive information that grants @@ -20,4 +20,4 @@ runtime: nodejs8 env_variables: MJ_APIKEY_PUBLIC: MJ_APIKEY_PRIVATE: -# [END app_yaml] +# [END gae_mailjet_yaml] diff --git a/appengine/memcached/app.flexible.yaml b/appengine/memcached/app.flexible.yaml index f121fccda6..a8f4e8b7fd 100644 --- a/appengine/memcached/app.flexible.yaml +++ b/appengine/memcached/app.flexible.yaml @@ -11,11 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env_variables] +# [START gae_flex_redislabs_memcache_yaml] # 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. @@ -25,5 +24,4 @@ env_variables: # 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] +# [END gae_flex_redislabs_memcache_yaml] diff --git a/appengine/memcached/app.js b/appengine/memcached/app.js index 4f0cfa5de2..05b4db55d9 100644 --- a/appengine/memcached/app.js +++ b/appengine/memcached/app.js @@ -13,7 +13,6 @@ * limitations under the License. */ -// [START app] 'use strict'; const express = require('express'); @@ -21,14 +20,13 @@ const memjs = require('memjs'); const app = express(); -// [START client] +// [START gae_flex_redislabs_memcache] // Environment variables are defined in app.yaml. let MEMCACHE_URL = process.env.MEMCACHE_URL; const mc = memjs.Client.create(MEMCACHE_URL); -// [END client] +// [END gae_flex_redislabs_memcache] -// [START example] app.get('/', (req, res, next) => { mc.get('foo', (err, value) => { if (err) { @@ -49,11 +47,9 @@ app.get('/', (req, res, next) => { }, 60); }); }); -// [END example] 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/memcached/app.standard.yaml b/appengine/memcached/app.standard.yaml index e3801afecd..4f1694747e 100644 --- a/appengine/memcached/app.standard.yaml +++ b/appengine/memcached/app.standard.yaml @@ -11,10 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env_variables] +# [START gae_flex_redislabs_memcache_yaml] # 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. @@ -24,5 +23,4 @@ env_variables: # 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] +# [END gae_flex_redislabs_memcache_yaml] diff --git a/appengine/pubsub/app.flexible.yaml b/appengine/pubsub/app.flexible.yaml index 271aaeccd6..9a6c500a28 100644 --- a/appengine/pubsub/app.flexible.yaml +++ b/appengine/pubsub/app.flexible.yaml @@ -11,15 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env] +# [START gae_flex_pubsub_yaml] 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] +# [END gae_flex_pubsub_yaml] diff --git a/appengine/pubsub/app.js b/appengine/pubsub/app.js index ea7b1390c8..efd366d596 100644 --- a/appengine/pubsub/app.js +++ b/appengine/pubsub/app.js @@ -13,7 +13,6 @@ * limitations under the License. */ -// [START app] 'use strict'; const express = require('express'); @@ -49,7 +48,7 @@ const PUBSUB_VERIFICATION_TOKEN = process.env.PUBSUB_VERIFICATION_TOKEN; const topic = pubsub.topic(process.env.PUBSUB_TOPIC); const publisher = topic.publisher(); -// [START index] +// [START gae_flex_pubsub_index] app.get('/', (req, res) => { res.render('index', { messages: messages }); }); @@ -68,9 +67,9 @@ app.post('/', formBodyParser, (req, res, next) => { res.status(200).send('Message sent'); }); }); -// [END index] +// [END gae_flex_pubsub_index] -// [START push] +// [START gae_flex_pubsub_push] app.post('/pubsub/push', jsonBodyParser, (req, res) => { if (req.query.token !== PUBSUB_VERIFICATION_TOKEN) { res.status(400).send(); @@ -84,7 +83,7 @@ app.post('/pubsub/push', jsonBodyParser, (req, res) => { res.status(200).send(); }); -// [END push] +// [END gae_flex_pubsub_push] // Start the server const PORT = process.env.PORT || 8080; @@ -92,6 +91,5 @@ 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/pubsub/app.standard.yaml b/appengine/pubsub/app.standard.yaml index b21f713f64..58f8b8c677 100644 --- a/appengine/pubsub/app.standard.yaml +++ b/appengine/pubsub/app.standard.yaml @@ -11,18 +11,14 @@ # 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] +# [START gae_flex_pubsub_yaml] 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] +# [END gae_flex_pubsub_yaml] diff --git a/appengine/pubsub/views/index.pug b/appengine/pubsub/views/index.pug index 28860613ba..a8350a48f0 100644 --- a/appengine/pubsub/views/index.pug +++ b/appengine/pubsub/views/index.pug @@ -13,8 +13,6 @@ html(lang='en') Note: because your application is likely running multiple instances, each instance will have a different list of messages. - //- [START form] form(method='post') textarea(name='payload', placeholder='Enter message here.') button(type='submit') Send - //- [END form] diff --git a/appengine/redis/server.js b/appengine/redis/server.js index e6505b02f0..29d1412880 100644 --- a/appengine/redis/server.js +++ b/appengine/redis/server.js @@ -24,7 +24,7 @@ const nconf = require('nconf'); // but you can also store them in environment variables nconf.argv().env().file('keys.json'); -// [START client] +// [START gae_flex_node_redis] // Connect to a redis server provisioned over at // Redis Labs. See the README for more info. const client = redis.createClient( @@ -35,7 +35,7 @@ const client = redis.createClient( 'return_buffers': true } ).on('error', (err) => console.error('ERR:REDIS:', err)); -// [END client] +// [END gae_flex_node_redis]] // Create a simple little server. http.createServer((req, res) => { diff --git a/appengine/sendgrid/app.flexible.yaml b/appengine/sendgrid/app.flexible.yaml index 79b79795bb..eed4ffe4c1 100644 --- a/appengine/sendgrid/app.flexible.yaml +++ b/appengine/sendgrid/app.flexible.yaml @@ -11,16 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env_variables] +# [START gae_flex_sendgrid_yaml] # 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: -# [END env_variables] -# [END app_yaml] +# [END gae_flex_sendgrid_yaml] diff --git a/appengine/sendgrid/app.js b/appengine/sendgrid/app.js index 3eb5753fcf..a8f19c6c2c 100644 --- a/appengine/sendgrid/app.js +++ b/appengine/sendgrid/app.js @@ -13,21 +13,19 @@ * limitations under the License. */ -// [START app] +// [START gae_flex_sendgrid] 'use strict'; const express = require('express'); const path = require('path'); const bodyParser = require('body-parser'); -// [START setup] // 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; const Sendgrid = require('sendgrid')(SENDGRID_API_KEY); -// [END setup] const app = express(); @@ -38,13 +36,10 @@ app.set('view engine', 'pug'); // Parse form data app.use(bodyParser.urlencoded({ extended: false })); -// [START index] app.get('/', (req, res) => { res.render('index'); }); -// [END index] -// [START hello] app.post('/hello', (req, res, next) => { const sgReq = Sendgrid.emptyRequest({ method: 'POST', @@ -73,17 +68,14 @@ app.post('/hello', (req, res, next) => { }); }); }); -// [END hello] if (module === require.main) { - // [START 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 server] } module.exports = app; -// [END app] +// [END gae_flex_sendgrid] diff --git a/appengine/sendgrid/app.standard.yaml b/appengine/sendgrid/app.standard.yaml index 6feded5bf8..d967c52106 100644 --- a/appengine/sendgrid/app.standard.yaml +++ b/appengine/sendgrid/app.standard.yaml @@ -11,15 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env_variables] +# [START gae_sendgrid_yaml] # 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: -# [END env_variables] -# [END app_yaml] +# [END gae_sendgrid_yaml] diff --git a/appengine/static-files/app.flexible.yaml b/appengine/static-files/app.flexible.yaml index 248738be70..41e9fef5d7 100644 --- a/appengine/static-files/app.flexible.yaml +++ b/appengine/static-files/app.flexible.yaml @@ -11,7 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [END app_yaml] diff --git a/appengine/static-files/app.js b/appengine/static-files/app.js index d839b35563..54baca8a1a 100644 --- a/appengine/static-files/app.js +++ b/appengine/static-files/app.js @@ -13,7 +13,7 @@ * limitations under the License. */ -// [START app] +// [START gae_flex_node_static_files] 'use strict'; const express = require('express'); @@ -34,4 +34,4 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] +// [END gae_flex_node_static_files] diff --git a/appengine/static-files/app.standard.yaml b/appengine/static-files/app.standard.yaml index 51487c8bca..edd055ff0e 100644 --- a/appengine/static-files/app.standard.yaml +++ b/appengine/static-files/app.standard.yaml @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 handlers: @@ -20,4 +19,3 @@ handlers: - url: /.* script: auto -# [END app_yaml] diff --git a/appengine/static-files/public/main.css b/appengine/static-files/public/main.css index 478845edb6..fc5766f61b 100644 --- a/appengine/static-files/public/main.css +++ b/appengine/static-files/public/main.css @@ -13,9 +13,9 @@ 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 example] */ +/* [START gae_flex_node_css] */ body { font-family: Verdana, Helvetica, sans-serif; background-color: #CCCCFF; } -/* [END example] */ +/* [END gae_flex_node_css] */ diff --git a/appengine/storage/flexible/app.js b/appengine/storage/flexible/app.js index 20be9f2668..cedb34f061 100644 --- a/appengine/storage/flexible/app.js +++ b/appengine/storage/flexible/app.js @@ -17,7 +17,7 @@ const process = require('process'); // Required to mock environment variables -// [START app] +// [START gae_flex_storage_app] const format = require('util').format; const express = require('express'); const Multer = require('multer'); @@ -37,7 +37,6 @@ 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({ @@ -49,16 +48,12 @@ const multer = Multer({ // 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) { @@ -82,13 +77,12 @@ app.post('/upload', multer.single('file'), (req, res, next) => { 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] +// [END gae_flex_storage_app] module.exports = app; diff --git a/appengine/storage/flexible/app.yaml b/appengine/storage/flexible/app.yaml index 44f7048bf7..bc7994b422 100644 --- a/appengine/storage/flexible/app.yaml +++ b/appengine/storage/flexible/app.yaml @@ -11,12 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] +# [START gae_flex_storage_yaml] runtime: nodejs env: flex -# [START env] env_variables: GCLOUD_STORAGE_BUCKET: YOUR_BUCKET_NAME -# [END env] -# [END app_yaml] +# [END gae_flex_storage_yaml] diff --git a/appengine/storage/standard/app.js b/appengine/storage/standard/app.js index 71cdc51d28..bc0eb31d4a 100644 --- a/appengine/storage/standard/app.js +++ b/appengine/storage/standard/app.js @@ -17,7 +17,7 @@ const process = require('process'); // Required to mock environment variables -// [START app] +// [START gae_storage_app] const format = require('util').format; const express = require('express'); const Multer = require('multer'); @@ -37,7 +37,6 @@ 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({ @@ -49,16 +48,12 @@ const multer = Multer({ // 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) { @@ -84,13 +79,12 @@ app.post('/upload', multer.single('file'), (req, res, next) => { 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] +// [END gae_storage_app] module.exports = app; diff --git a/appengine/storage/standard/app.yaml b/appengine/storage/standard/app.yaml index 420e663d1f..f87e0a72e2 100644 --- a/appengine/storage/standard/app.yaml +++ b/appengine/storage/standard/app.yaml @@ -11,11 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] +# [START gae_storage_yaml] runtime: nodejs8 -# [START env] env_variables: GCLOUD_STORAGE_BUCKET: YOUR_BUCKET_NAME -# [END env] -# [END app_yaml] +# [END gae_storage_yaml] diff --git a/appengine/twilio/app.flexible.yaml b/appengine/twilio/app.flexible.yaml index a981d75ddd..1f0fbe241e 100644 --- a/appengine/twilio/app.flexible.yaml +++ b/appengine/twilio/app.flexible.yaml @@ -11,11 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs env: flex -# [START env_variables] +# [START gae_flex_twilio_env] # 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. @@ -23,5 +22,4 @@ env_variables: TWILIO_ACCOUNT_SID: TWILIO_AUTH_TOKEN: TWILIO_NUMBER: -# [END env_variables] -# [END app_yaml] +# [END gae_flex_twilio_env] diff --git a/appengine/twilio/app.js b/appengine/twilio/app.js index 0690290fd8..3d57103d6c 100644 --- a/appengine/twilio/app.js +++ b/appengine/twilio/app.js @@ -13,7 +13,6 @@ * limitations under the License. */ -// [START app] 'use strict'; const format = require('util').format; @@ -24,7 +23,6 @@ const bodyParser = require('body-parser').urlencoded({ const app = express(); -// [START config] const TWILIO_NUMBER = process.env.TWILIO_NUMBER; if (!TWILIO_NUMBER) { console.log('Please configure environment variables as described in README.md'); @@ -37,9 +35,8 @@ const twilio = require('twilio')( ); const TwimlResponse = require('twilio').TwimlResponse; -// [END config] -// [START receive_call] +// [START gae_flex_twilio_receive_call] app.post('/call/receive', (req, res) => { const resp = new TwimlResponse(); resp.say('Hello from Google App Engine.'); @@ -48,9 +45,9 @@ app.post('/call/receive', (req, res) => { .contentType('text/xml') .send(resp.toString()); }); -// [END receive_call] +// [END gae_flex_twilio_receive_call] -// [START send_sms] +// [START gae_flex_twilio_send_sms] app.get('/sms/send', (req, res, next) => { const to = req.query.to; if (!to) { @@ -70,9 +67,9 @@ app.get('/sms/send', (req, res, next) => { res.status(200).send('Message sent.'); }); }); -// [END send_sms] +// [END gae_flex_twilio_send_sms] -// [START receive_sms] +// [START gae_flex_twilio_receive_sms] app.post('/sms/receive', bodyParser, (req, res) => { const sender = req.body.From; const body = req.body.Body; @@ -84,7 +81,7 @@ app.post('/sms/receive', bodyParser, (req, res) => { .contentType('text/xml') .send(resp.toString()); }); -// [END receive_sms] +// [END gae_flex_twilio_receive_sms] // Start the server const PORT = process.env.PORT; @@ -92,4 +89,3 @@ app.listen(PORT, () => { console.log(`App listening on port ${PORT}`); console.log('Press Ctrl+C to quit.'); }); -// [END app] diff --git a/appengine/twilio/app.standard.yaml b/appengine/twilio/app.standard.yaml index 85fe77ab80..fb7c3fb57e 100644 --- a/appengine/twilio/app.standard.yaml +++ b/appengine/twilio/app.standard.yaml @@ -11,10 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# [START app_yaml] runtime: nodejs8 -# [START env_variables] +# [START gae_twilio_env] # 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. @@ -22,5 +21,4 @@ env_variables: TWILIO_ACCOUNT_SID: TWILIO_AUTH_TOKEN: TWILIO_NUMBER: -# [END env_variables] -# [END app_yaml] +# [END gae_twilio_env]