Skip to content

Commit ea6c1ec

Browse files
camiekimpattishinkweinmeister
authored
docs: Add sample app for invoking private endpoint documentation (#3270)
* Update workflows.json * Create app.js * Create package.json * Create README.md * Create app.test.js * Update app.test.js --------- Co-authored-by: Patti Shin <[email protected]> Co-authored-by: Karl Weinmeister <[email protected]>
1 parent 62b70e8 commit ea6c1ec

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

.github/workflows/utils/workflows.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@
9191
"translate",
9292
"video-intelligence",
9393
"vision/productSearch",
94-
"workflows"
94+
"workflows",
95+
"workflows/invoke-private-endpoint"
9596
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Node.js sample for "Invoke a VPC Service Controls-compliant private endpoint"
2+
3+
This is the sample application for the
4+
[Invoke a VPC Service Controls-compliant private endpoint](https://cloud.google.com/workflows/docs/invoke-private-endpoint-vpc)
5+
page found in the [Google Cloud Workflows](https://cloud.google.com/workflows/docs) documentation.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2023 Google LLC
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+
// https://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+
'use strict';
16+
17+
// [START workflows_private_endpoint]
18+
const express = require('express');
19+
const app = express();
20+
21+
app.get('/', (req, res) => {
22+
res.status(200).send('Hello, world!').end();
23+
});
24+
25+
app.listen(3000, () => {
26+
console.log('Sample app listening on port 3000.');
27+
});
28+
// [END workflows_private_endpoint]
29+
30+
module.exports = app;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "workflows-hello-private-endpoint",
3+
"description": "Simple Hello World Node.js sample for Workflows",
4+
"version": "1.0.0",
5+
"private": true,
6+
"license": "Apache-2.0",
7+
"author": "Google Inc.",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
11+
},
12+
"engines": {
13+
"node": ">=14.0.0"
14+
},
15+
"scripts": {
16+
"start": "node app.js",
17+
"test": "c8 mocha --exit test/*.test.js"
18+
},
19+
"dependencies": {
20+
"express": "^4.17.1"
21+
},
22+
"devDependencies": {
23+
"c8": "^7.13.0",
24+
"mocha": "^10.0.0",
25+
"supertest": "^6.0.0"
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2023 Google LLC
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+
// https://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+
const app = require('../app');
16+
const request = require('supertest');
17+
18+
describe('workflows_private_endpoint', () => {
19+
describe('GET /', () => {
20+
it('should get 200', done => {
21+
request(app).get('/').expect(200, done);
22+
});
23+
24+
it('should get Hello World', done => {
25+
request(app).get('/').expect('Hello, world!', done);
26+
});
27+
});
28+
});

0 commit comments

Comments
 (0)