Skip to content

Commit 4af9080

Browse files
authored
Revert "Upgrade apps for env:flex." (#242)
1 parent a4eb913 commit 4af9080

File tree

164 files changed

+1766
-1657
lines changed

Some content is hidden

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

164 files changed

+1766
-1657
lines changed

appengine/README.md

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

3-
These are samples for using Node.js on Google App Engine Flexible Environment. These
3+
These are samples for using Node.js on Google App Engine Managed VMs. These
44
samples are referenced from the [docs](https://cloud.google.com/appengine/docs).
55

66
See our other [Google Cloud Platform github repos](https://github.com/GoogleCloudPlatform)

appengine/analytics/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Google Analytics Measurement Protocol on Google App Engine
22

33
This sample demonstrates how to use the [Google Analytics Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/)
4-
(or any other SQL server) on [Google App Engine Flexible Environment](https://cloud.google.com/appengine).
4+
(or any other SQL server) on [Google App Engine Managed VMs](https://cloud.google.com/appengine).
55

66
## Setup
77

appengine/analytics/app.js

+28-33
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
/**
2-
* Copyright 2016, 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-
*/
1+
// Copyright 2015-2016, Google, Inc.
2+
//
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.
1514

1615
// [START app]
1716
'use strict';
1817

1918
// [START setup]
20-
const express = require('express');
21-
const request = require('request');
19+
var express = require('express');
20+
var request = require('request');
2221

23-
const app = express();
22+
var app = express();
2423
app.enable('trust proxy');
2524
// [END setup]
2625

2726
// [START track]
2827
// The following environment variable is set by app.yaml when running on GAE,
2928
// but will need to be manually set when running locally. See README.md.
30-
const GA_TRACKING_ID = process.env.GA_TRACKING_ID;
29+
var GA_TRACKING_ID = process.env.GA_TRACKING_ID;
3130

3231
function trackEvent (category, action, label, value, cb) {
33-
const data = {
32+
var data = {
3433
v: '1', // API Version.
3534
tid: GA_TRACKING_ID, // Tracking ID / Property ID.
3635
// Anonymous Client Identifier. Ideally, this should be a UUID that
@@ -44,18 +43,15 @@ function trackEvent (category, action, label, value, cb) {
4443
};
4544

4645
request.post(
47-
'http://www.google-analytics.com/collect',
48-
{
46+
'http://www.google-analytics.com/collect', {
4947
form: data
5048
},
51-
(err, response) => {
49+
function (err, response) {
5250
if (err) {
53-
cb(err);
54-
return;
51+
return cb(err);
5552
}
5653
if (response.statusCode !== 200) {
57-
cb(new Error('Tracking failed'));
58-
return;
54+
return cb(new Error('Tracking failed'));
5955
}
6056
cb();
6157
}
@@ -64,29 +60,28 @@ function trackEvent (category, action, label, value, cb) {
6460
// [END track]
6561

6662
// [START endpoint]
67-
app.get('/', (req, res, next) => {
63+
app.get('/', function (req, res, next) {
6864
trackEvent(
6965
'Example category',
7066
'Example action',
7167
'Example label',
7268
'100', // Event value must be numeric.
73-
(err) => {
69+
function (err) {
7470
// This sample treats an event tracking error as a fatal error. Depending
7571
// on your application's needs, failing to track an event may not be
7672
// considered an error.
7773
if (err) {
78-
next(err);
79-
return;
74+
return next(err);
8075
}
8176
res.status(200).send('Event tracked.');
8277
});
8378
});
8479
// [END endpoint]
8580

8681
// [START listen]
87-
const PORT = process.env.PORT || 8080;
88-
app.listen(PORT, () => {
89-
console.log(`App listening on port ${PORT}`);
82+
var PORT = process.env.PORT || 8080;
83+
app.listen(PORT, function () {
84+
console.log('App listening on port %s', PORT);
9085
console.log('Press Ctrl+C to quit.');
9186
});
9287
// [END listen]

appengine/analytics/app.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2015-2016, Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -13,7 +13,7 @@
1313

1414
# [START app_yaml]
1515
runtime: nodejs
16-
env: flex
16+
vm: true
1717

1818
# [START env]
1919
env_variables:

appengine/analytics/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
"license": "Apache Version 2.0",
77
"author": "Google Inc.",
88
"engines": {
9-
"node": ">=4.3.2"
9+
"node": "~4.2"
1010
},
1111
"scripts": {
1212
"start": "node app.js",
1313
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../../test/_setup.js test/*.test.js"
1414
},
1515
"dependencies": {
16-
"express": "^4.14.0",
17-
"request": "^2.75.0"
16+
"express": "^4.13.4",
17+
"request": "^2.69.0"
1818
},
1919
"devDependencies": {
20-
"mocha": "^3.1.0"
20+
"mocha": "^2.5.3"
2121
}
2222
}

appengine/analytics/test/app.test.js

+39-42
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
1-
/**
2-
* Copyright 2016, 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-
*/
1+
// Copyright 2016, 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.
1513

1614
'use strict';
1715

18-
const express = require(`express`);
19-
const path = require(`path`);
20-
const proxyquire = require(`proxyquire`).noPreserveCache();
21-
const request = require(`supertest`);
16+
var express = require('express');
17+
var path = require('path');
18+
var proxyquire = require('proxyquire').noPreserveCache();
19+
var request = require('supertest');
2220

23-
const SAMPLE_PATH = path.join(__dirname, `../app.js`);
21+
var SAMPLE_PATH = path.join(__dirname, '../app.js');
2422

2523
function getSample () {
26-
const testApp = express();
27-
sinon.stub(testApp, `listen`).callsArg(1);
28-
const expressMock = sinon.stub().returns(testApp);
29-
const resultsMock = {
24+
var testApp = express();
25+
sinon.stub(testApp, 'listen').callsArg(1);
26+
var expressMock = sinon.stub().returns(testApp);
27+
var resultsMock = {
3028
statusCode: 200,
31-
foo: `bar`
29+
foo: 'bar'
3230
};
3331

34-
const requestMock = {
35-
post: sinon.stub().yields(null, resultsMock)
32+
var requestMock = {
33+
post: sinon.stub().callsArgWith(2, null, resultsMock)
3634
};
3735

38-
const app = proxyquire(SAMPLE_PATH, {
36+
var app = proxyquire(SAMPLE_PATH, {
3937
request: requestMock,
4038
express: expressMock
4139
});
42-
4340
return {
4441
app: app,
4542
mocks: {
@@ -50,52 +47,52 @@ function getSample () {
5047
};
5148
}
5249

53-
describe(`appengine/analytics/app.js`, () => {
54-
let sample;
50+
describe('appengine/analytics/app.js', function () {
51+
var sample;
5552

56-
beforeEach(() => {
53+
beforeEach(function () {
5754
sample = getSample();
5855

5956
assert(sample.mocks.express.calledOnce);
6057
assert(sample.app.listen.calledOnce);
6158
assert.equal(sample.app.listen.firstCall.args[0], process.env.PORT || 8080);
6259
});
6360

64-
it(`should record a visit`, (done) => {
65-
const expectedResult = `Event tracked.`;
61+
it('should record a visit', function (done) {
62+
var expectedResult = 'Event tracked.';
6663

6764
request(sample.app)
68-
.get(`/`)
65+
.get('/')
6966
.expect(200)
70-
.expect((response) => {
67+
.expect(function (response) {
7168
assert.equal(response.text, expectedResult);
7269
})
7370
.end(done);
7471
});
7572

76-
it(`should handle request error`, (done) => {
77-
const expectedResult = `request_error`;
73+
it('should handle request error', function (done) {
74+
var expectedResult = 'request_error';
7875

7976
sample.mocks.request.post.onFirstCall().callsArgWith(2, expectedResult);
8077

8178
request(sample.app)
82-
.get(`/`)
79+
.get('/')
8380
.expect(500)
84-
.expect((response) => {
85-
assert.equal(response.text, expectedResult + `\n`);
81+
.expect(function (response) {
82+
assert.equal(response.text, expectedResult + '\n');
8683
})
8784
.end(done);
8885
});
8986

90-
it(`should handle track error`, (done) => {
87+
it('should handle track error', function (done) {
9188
sample.mocks.request.post.onFirstCall().callsArgWith(2, null, {
9289
statusCode: 400
9390
});
9491

9592
request(sample.app)
9693
.get('/')
9794
.expect(500)
98-
.expect((response) => {
95+
.expect(function (response) {
9996
assert.notEqual(response.text.indexOf('Error: Tracking failed'), -1);
10097
})
10198
.end(done);

appengine/bower/app.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2015-2016, Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -13,5 +13,5 @@
1313

1414
# [START app_yaml]
1515
runtime: nodejs
16-
env: flex
16+
vm: true
1717
# [END app_yaml]

appengine/bower/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
"license": "Apache Version 2.0",
77
"author": "Google Inc.",
88
"engines": {
9-
"node": ">=4.3.2"
9+
"node": "~4.2"
1010
},
1111
"scripts": {
1212
"postinstall": "bower install --config.interactive=false",
1313
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../../test/_setup.js test/*.test.js"
1414
},
1515
"dependencies": {
16-
"bower": "^1.7.9",
17-
"express": "^4.14.0",
18-
"pug": "^2.0.0-beta6"
16+
"bower": "^1.7.7",
17+
"express": "^4.13.4",
18+
"jade": "^1.11.0"
1919
},
2020
"devDependencies": {
21-
"mocha": "^3.1.0"
21+
"mocha": "^2.5.3"
2222
}
2323
}

0 commit comments

Comments
 (0)