Skip to content

Commit

Permalink
fix: update run/helloworld to use esmodules (GoogleCloudPlatform#3615)
Browse files Browse the repository at this point in the history
* fix: update run/helloworld to esmodules

* fix: lint

* fix: gts fix
  • Loading branch information
glasnt committed Jan 24, 2024
1 parent 62253bb commit 4e90a2b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"node/no-unpublished-import": ["off"],
"node/no-unpublished-require": ["off"],
"node/no-unsupported-features/es-syntax": ["off"]
},
"parserOptions": {
"sourceType": "module"
}
}
4 changes: 2 additions & 2 deletions run/helloworld/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// [START cloudrun_helloworld_service]
// [START run_helloworld_service]
const express = require('express');
import express from 'express';
const app = express();

app.get('/', (req, res) => {
Expand All @@ -30,4 +30,4 @@ app.listen(port, () => {
// [END cloudrun_helloworld_service]

// Exports for testing purposes.
module.exports = app;
export default app;
1 change: 1 addition & 0 deletions run/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "c8 mocha -p -j 2 test/index.test.js --exit",
"system-test": "NAME=Cloud c8 mocha -p -j 2 test/system.test.js --timeout=180000"
},
"type": "module",
"engines": {
"node": ">=16.0.0"
},
Expand Down
7 changes: 3 additions & 4 deletions run/helloworld/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
import assert from 'assert';
import supertest from 'supertest';
import app from '../index.js';

let request;
describe('Unit Tests', () => {
before(() => {
const app = require(path.join(__dirname, '..', 'index'));
request = supertest(app);
});

Expand Down
8 changes: 4 additions & 4 deletions run/helloworld/test/system.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const assert = require('assert');
const {execSync} = require('child_process');
const request = require('got');
const {GoogleAuth} = require('google-auth-library');
import assert from 'assert';
import {execSync} from 'child_process';
import request from 'got';
import {GoogleAuth} from 'google-auth-library';
const auth = new GoogleAuth();

const get = (route, base_url) => {
Expand Down

0 comments on commit 4e90a2b

Please sign in to comment.