Skip to content

Commit

Permalink
fix: Updating the node environment to Node.js 20 (#3617)
Browse files Browse the repository at this point in the history
* fix: Updating the node environment to Node.js 20

Signed-off-by: Jennifer Davis <[email protected]>

* chore: remove unmaintained sample

Signed-off-by: Jennifer Davis <[email protected]>

* chore: removing twilio sample

Signed-off-by: Jennifer Davis <[email protected]>

* fix: restore region tag in prep for deletion

* fix: update copyright header based on policy

* fix: update Copyright header based on policy

* fix: restore region tag

* fix: header copyright policy

* fix: update header copyright policy

* fix: restore region tags

* fix: restore region tags Update server.js

* fix: add new region tags to tests

should resolve region-tag-tests issues

* fix: resolve missing ; from server.test.js

* fix: resolve license compliance issues with server.test.js

* fix: resolve comment server.test.js

* fix: headerlint

---------

Signed-off-by: Jennifer Davis <[email protected]>
Co-authored-by: Patti Shin <[email protected]>
Co-authored-by: Katie McLaughlin <[email protected]>
  • Loading branch information
3 people authored Apr 16, 2024
1 parent 79b97af commit 4f5a7fe
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 391 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/appengine-twilio.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/utils/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"appengine/static-files",
"appengine/storage/flexible",
"appengine/storage/standard",
"appengine/twilio",
"appengine/typescript",
"appengine/websockets",
"asset/snippets",
Expand Down
6 changes: 4 additions & 2 deletions appengine/building-an-app/build/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018, Google, Inc.
# Copyright 2018 Google LLC
# 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
Expand All @@ -12,5 +12,7 @@
# limitations under the License.

# [START app_yaml]
runtime: nodejs16
# [START gae_app_yaml]
runtime: nodejs20
# [END gae_app_yaml]
# [END app_yaml]
6 changes: 3 additions & 3 deletions appengine/building-an-app/build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appengine-standard-getting-started-build-apps",
"version": "0.0.1",
"version": "0.1.0",
"description": "Node.js getting started sample for building an app on App Engine standard environment.",
"private": true,
"main": "server.js",
Expand All @@ -14,12 +14,12 @@
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": "16.x.x"
"node": "20.x.x"
},
"author": "Google Inc.",
"license": "Apache-2.0",
"dependencies": {
"express": "^4.16.3"
"express": "^4.18.2"
},
"devDependencies": {
"c8": "^8.0.0",
Expand Down
2 changes: 2 additions & 0 deletions appengine/building-an-app/build/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

// [START app]
// [START gae_app]
const express = require('express');
const app = express();

Expand All @@ -27,6 +28,7 @@ const PORT = parseInt(process.env.PORT) || 8080;
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}...`);
});
// [END gae_app]
// [END app]

module.exports = app;
21 changes: 18 additions & 3 deletions appengine/building-an-app/build/test/server.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
// Copyright 2018 Google LLC
// 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.

const supertest = require('supertest');
const path = require('path');
const app = require(path.join(__dirname, '../', 'server.js'));


it('should be listening', async () => {
await supertest(app).get('/').expect(200);
});
describe('gae_app', () => {
it('should be listening', async () => {
await supertest(app).get('/').expect(200);
});
})
4 changes: 2 additions & 2 deletions appengine/building-an-app/update/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018, Google, Inc.
# Copyright 2018 Google LLC
# 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
Expand All @@ -12,5 +12,5 @@
# limitations under the License.

# [START app_yaml]
runtime: nodejs16
runtime: nodejs20
# [END app_yaml]
6 changes: 3 additions & 3 deletions appengine/building-an-app/update/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appengine-standard-getting-started-update-apps",
"version": "0.0.1",
"version": "0.1.0",
"description": "Node.js getting started sample for updating an app on App Engine standard environment.",
"private": true,
"main": "server.js",
Expand All @@ -14,12 +14,12 @@
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": "16.x.x"
"node": "20.x.x"
},
"author": "Google Inc.",
"license": "Apache-2.0",
"dependencies": {
"express": "^4.16.3"
"express": "^4.18.2"
},
"devDependencies": {
"c8": "^8.0.0",
Expand Down
8 changes: 8 additions & 0 deletions appengine/building-an-app/update/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,49 @@
'use strict';

// [START app]
// [START gae_update_app]
const express = require('express');
const path = require('path');

const app = express();

// [START enable_parser]
// [START gae_enable_parser]
// This middleware is available in Express v4.16.0 onwards
app.use(express.urlencoded({extended: true}));
// [END gae_enable_parser]
// [END enable_parser]

app.get('/', (req, res) => {
res.send('Hello from App Engine!');
});

// [START add_display_form]
// [START gae_add_display_form]
app.get('/submit', (req, res) => {
res.sendFile(path.join(__dirname, '/views/form.html'));
});
// [END gae_add_display_form]
// [END add_display_form]

// [START add_post_handler]
// [START gae_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 gae_add_post_handler]
// [END add_post_handler]

// Listen to the App Engine-specified port, or 8080 otherwise
const PORT = parseInt(process.env.PORT) || 8080;
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}...`);
});
// [END gae_update_app]
// [END app]

module.exports = app;
22 changes: 12 additions & 10 deletions appengine/building-an-app/update/test/server.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018, Google, Inc.
// Copyright 2018 Google LLC
// 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
Expand Down Expand Up @@ -36,16 +36,18 @@ const restoreConsole = function () {
beforeEach(stubConsole);
afterEach(restoreConsole);

it('should send greetings', async () => {
await requestObj
.get('/')
.expect(200)
.expect(response => {
assert.strictEqual(response.text, 'Hello from App Engine!');
});
describe('gae_update_app', () => {
it('should send greetings', async () => {
await requestObj
.get('/')
.expect(200)
.expect(response => {
assert.strictEqual(response.text, 'Hello from App Engine!');
});
});
});

describe('add_display_form', () => {
describe('gae_add_display_form add_display_form', () => {
it('should display form', async () => {
await requestObj
.get('/submit')
Expand All @@ -61,7 +63,7 @@ describe('add_display_form', () => {
});
});

describe('add_post_handler enable_parser', () => {
describe('gae_add_post_handler add_post_handler gae_enable_parser enable_parser', () => {
it('should record message', async () => {
await requestObj
.post('/submit', {
Expand Down
36 changes: 0 additions & 36 deletions appengine/twilio/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions appengine/twilio/app.flexible.yaml

This file was deleted.

Loading

0 comments on commit 4f5a7fe

Please sign in to comment.