Skip to content

Commit c11163d

Browse files
author
chenyumic
authored
Merge samples for Flex and Std (#590)
* Merge samples for Flex and Std * Solve conflicts * MInor Fixes * More minor fixes * Lint * Applied requested changes
1 parent daf141d commit c11163d

File tree

108 files changed

+1511
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1511
-139
lines changed

appengine/README.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Google App Engine Node.js Samples
22

33
These are samples for using [Node.js][nodejs] on
4-
[Google App Engine Flexible Environment][appengine]. Many of these samples
4+
[Google App Engine][appengine]. Many of these samples
55
are referenced from the documentation on [cloud.google.com][appengine].
66

77
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:
5757

5858
## Deploying
5959

60-
Some samples in this repositories may have special deployment instructions.
60+
Some samples may have special deployment instructions.
6161
Refer to the `README.md` file in the sample folder.
6262

63+
Many samples in this folder can be deployed to both App Engine Node.js standard
64+
environment and flexible environment. Those samples come with two different
65+
App Engine configuration files: `app.flexible.yaml` for flexible environment,
66+
and `app.standard.yaml` for standard environment.
67+
68+
Samples with one single configuration file, `app.yaml`, can only be deployed
69+
to one of the two environments. See the `README.md` files for these samples
70+
for more information.
71+
72+
Generally speaking, to deploy a sample application:
73+
6374
1. Use the [Google Cloud Console][console] to create a Google Cloud Platform
6475
project.
6576
1. [Enable billing][billing] for your project.
6677

6778
1. Use the Cloud SDK to deploy your app.
6879

80+
For samples with two configuration files (`app.flexible.yaml` and
81+
`app.standard.yaml`), if you plan to use App Engine Node.js Standard
82+
Environment, run
83+
84+
gcloud app deploy app.standard.yaml
85+
86+
To deploy to App Engine Node.js Flexible Environment, run
87+
88+
gcloud app deploy app.flexible.yaml
89+
90+
For samples with one configuration file (`app.yaml`), run
91+
6992
gcloud app deploy
7093

94+
to deploy the app to its compatible environment.
95+
7196
Note: If there is a `yarn.lock` file then `yarn install` will be used during
7297
deployment. Delete the `yarn.lock` file to fall back to `npm install`.
7398

@@ -82,7 +107,7 @@ View the [Official App Engine Node.js samples][official_samples].
82107
View the [Community-contributed App Engine Node.js samples][community_samples].
83108

84109
[nodejs]: https://nodejs.org/
85-
[appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs/
110+
[appengine]: https://cloud.google.com/appengine/
86111
[nodejs_dev]: https://cloud.google.com/community/tutorials/how-to-prepare-a-nodejs-dev-environment
87112
[sdk]: https://cloud.google.com/sdk/
88113
[console]: https://console.cloud.google.com

appengine/analytics/README.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Integrating with Google Analytics
22

3-
This is the sample application for the
4-
[Integrating with Google Analytics tutorial][tutorial] tutorial found in the
5-
[Google App Engine Node.js Flexible Environment][appengine] documentation.
3+
This sample application shows how to integrate your Node.js application with
4+
Google Analytics on Google App Engine.
5+
6+
[App Engine standard environment][appengine-std] users: See tutorial [Integrating with Google Analytics][std-tutorial] for more information on running and deploying this app.
7+
8+
[App Engine flexible environment][appengine-flex] users: See tutorial [Integrating with Google Analytics][flex-tutorial] for more information on running and deploying this app.
69

710
* [Setup](#setup)
811
* [Running locally](#running-locally)
@@ -37,22 +40,27 @@ or with `yarn`:
3740

3841
GA_TRACKING_ID=YOUR_TRACKING_ID yarn start
3942

40-
## Deploying to App Engine
43+
## Deploying to App Engine standard Environment
4144

42-
With `npm`:
45+
```
46+
gcloud app deploy app.standard.yaml
47+
```
4348

44-
npm run deploy
49+
## Deploying to App Engine flexible Environment
4550

46-
or with `yarn`:
51+
```
52+
gcloud app deploy app.flexible.yaml
53+
```
4754

48-
yarn run deploy
4955

5056
## Running the tests
5157

5258
See [Contributing][contributing].
5359

54-
[appengine]: https://cloud.google.com/appengine/docs/flexible/nodejs
55-
[tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/integrating-with-analytics
60+
[appengine-flex]: https://cloud.google.com/appengine/docs/flexible/nodejs
61+
[appengine-std]: https://cloud.google.com/appengine/docs/standard/nodejs
62+
[flex-tutorial]: https://cloud.google.com/appengine/docs/flexible/nodejs/integrating-with-analytics
63+
[std-tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/integrating-with-analytics
5664
[readme]: ../README.md
5765
[tracking]: https://support.google.com/analytics/answer/1042508
5866
[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md
File renamed without changes.

appengine/analytics/app.standard.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2017, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# [START app_yaml]
15+
runtime: nodejs8
16+
17+
# [START env]
18+
env_variables:
19+
GA_TRACKING_ID: YOUR_TRACKING_ID
20+
# [END env]
21+
# [END app_yaml]

appengine/analytics/package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appengine-analytics",
3-
"description": "Sample for Google Analytics Measurement Protocol on Google App Engine Flexible Environment.",
3+
"description": "Sample for Google Analytics Measurement Protocol on Google App Engine.",
44
"version": "0.0.1",
55
"private": true,
66
"license": "Apache-2.0",
@@ -10,16 +10,14 @@
1010
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
1111
},
1212
"engines": {
13-
"node": ">=4"
13+
"node": "8.x.x"
1414
},
1515
"scripts": {
16-
"deploy": "gcloud app deploy",
1716
"start": "node app.js",
1817
"lint": "repo-tools lint",
1918
"pretest": "npm run lint",
2019
"system-test": "repo-tools test app",
21-
"test": "npm run system-test",
22-
"e2e-test": "repo-tools test deploy"
20+
"test": "npm run system-test"
2321
},
2422
"dependencies": {
2523
"express": "4.16.2",
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Writing Your Web Service Sample for Node.js in the App Engine Standard Environment
2+
3+
This is the sample application for the
4+
[Writing Your Web Service with Node.js][tutorial]
5+
tutorial found in the [Google App Engine Node.js standard environment][appengine]
6+
documentation.
7+
8+
* [Setup](#setup)
9+
* [Running locally](#running-locally)
10+
* [Deploying to App Engine](#deploying-to-app-engine)
11+
* [Running the tests](#running-the-tests)
12+
13+
## Setup
14+
15+
Before you can run or deploy the sample, you need to do the following:
16+
17+
1. Refer to the [appengine/README.md][readme] file for instructions on
18+
running and deploying.
19+
1. Install dependencies:
20+
21+
npm install
22+
23+
## Running locally
24+
25+
npm start
26+
27+
## Deploying to App Engine
28+
29+
gcloud app deploy
30+
31+
## Running the tests
32+
33+
See [Contributing][contributing].
34+
35+
[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs
36+
[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/writing-web-service
37+
[readme]: ../../README.md
38+
[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2018, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# [START app_yaml]
15+
runtime: nodejs8
16+
# [END app_yaml]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "appengine-standard-getting-started-build-apps",
3+
"version": "0.0.1",
4+
"description": "Node.js getting started sample for building an app on App Engine standard environment.",
5+
"private": true,
6+
"main": "server.js",
7+
"scripts": {
8+
"start": "node server.js",
9+
"deploy": "gcloud app deploy",
10+
"lint": "samples lint",
11+
"pretest": "npm run lint",
12+
"test": "samples test app"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
17+
},
18+
"engines": {
19+
"node": "8.x.x"
20+
},
21+
"author": "Google Inc.",
22+
"license": "Apache-2.0",
23+
"dependencies": {
24+
"express": "^4.16.3"
25+
},
26+
"devDependencies": {
27+
"@google-cloud/nodejs-repo-tools": "1.4.17",
28+
"ava": "0.22.0",
29+
"semistandard": "^12.0.1"
30+
},
31+
"cloud-repo-tools": {
32+
"requiresKeyFile": false,
33+
"requiresProjectId": false,
34+
"test": {
35+
"app": {
36+
"args": [
37+
"server.js"
38+
],
39+
"msg": "Hello from App Engine!"
40+
}
41+
}
42+
}
43+
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2018, Google, Inc.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
'use strict';
17+
18+
// [START app]
19+
const express = require('express');
20+
const app = express();
21+
22+
app.get('/', (req, res) => {
23+
res.send('Hello from App Engine!');
24+
});
25+
26+
// Listen to the App Engine-specified port, or 8080 otherwise
27+
const PORT = process.env.PORT || 8080;
28+
app.listen(PORT, () => {
29+
console.log(`Server listening on port ${PORT}...`);
30+
});
31+
// [END app]
32+
33+
module.exports = app;
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Updating Your Web Service Sample for Node.js in the App Engine Standard Environment
2+
3+
This is the sample application for the
4+
[Updating Your Web Service][tutorial]
5+
tutorial found in the [Google App Engine Node.js standard environment][appengine]
6+
documentation.
7+
8+
* [Setup](#setup)
9+
* [Running locally](#running-locally)
10+
* [Deploying to App Engine](#deploying-to-app-engine)
11+
* [Running the tests](#running-the-tests)
12+
13+
## Setup
14+
15+
Before you can run or deploy the sample, you need to do the following:
16+
17+
1. Refer to the [appengine/README.md][readme] file for instructions on
18+
running and deploying.
19+
1. Install dependencies:
20+
21+
npm install
22+
23+
## Running locally
24+
25+
npm start
26+
27+
## Deploying to App Engine
28+
29+
gcloud app deploy
30+
31+
## Running the tests
32+
33+
See [Contributing][contributing].
34+
35+
[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs
36+
[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/updating-web-service
37+
[readme]: ../../README.md
38+
[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2018, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# [START app_yaml]
15+
runtime: nodejs8
16+
# [END app_yaml]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "appengine-standard-getting-started-update-apps",
3+
"version": "0.0.1",
4+
"description": "Node.js getting started sample for updating an app on App Engine standard environment.",
5+
"private": true,
6+
"main": "server.js",
7+
"scripts": {
8+
"start": "node server.js",
9+
"deploy": "gcloud app deploy",
10+
"lint": "samples lint",
11+
"pretest": "npm run lint",
12+
"test": "ava --verbose test/*.test.js"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
17+
},
18+
"engines": {
19+
"node": "8.x.x"
20+
},
21+
"author": "Google Inc.",
22+
"license": "Apache-2.0",
23+
"dependencies": {
24+
"body-parser": "^1.18.2",
25+
"express": "^4.16.3",
26+
"semistandard": "^12.0.1"
27+
},
28+
"devDependencies": {
29+
"@google-cloud/nodejs-repo-tools": "1.4.17",
30+
"ava": "0.22.0",
31+
"semistandard": "^12.0.1"
32+
}
33+
}

0 commit comments

Comments
 (0)