Skip to content

Commit

Permalink
Apply ESLint (Node 8) + use delay package (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ace Nassri authored Jun 3, 2019
1 parent d51fee4 commit 216006f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
7 changes: 4 additions & 3 deletions endpoints/getting-started-grpc/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function makeGrpcRequest(JWT_AUTH_TOKEN, API_KEY, HOST, GREETEE) {
}

// The command-line program
const argv = require('yargs')
const {argv} = require('yargs')
.usage(
'Usage: node $0 {-k YOUR_API_KEY>, <-j YOUR_JWT_AUTH_TOKEN} [-h YOUR_ENDPOINTS_HOST] [-g GREETEE_NAME]'
)
Expand Down Expand Up @@ -92,7 +92,8 @@ const argv = require('yargs')
.wrap(120)
.help()
.strict()
.epilogue(`For more information, see https://cloud.google.com/endpoints/docs`)
.argv;
.epilogue(
`For more information, see https://cloud.google.com/endpoints/docs`
);

makeGrpcRequest(argv.jwtAuthToken, argv.apiKey, argv.host, argv.greetee);
1 change: 1 addition & 0 deletions endpoints/getting-started-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"delay": "^4.2.0",
"mocha": "^6.0.0"
},
"cloud-repo-tools": {
Expand Down
7 changes: 4 additions & 3 deletions endpoints/getting-started-grpc/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function startServer(PORT) {
}

// The command-line program
const argv = require('yargs')
const {argv} = require('yargs')
.usage('Usage: node $0 [-p PORT]')
.option('port', {
alias: 'p',
Expand All @@ -44,7 +44,8 @@ const argv = require('yargs')
global: true,
})
.wrap(120)
.epilogue(`For more information, see https://cloud.google.com/endpoints/docs`)
.argv;
.epilogue(
`For more information, see https://cloud.google.com/endpoints/docs`
);

startServer(argv.port);
19 changes: 6 additions & 13 deletions endpoints/getting-started-grpc/system-test/endpoints.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const assert = require('assert');
const fs = require(`fs`);
const jwt = require('jsonwebtoken');
const tools = require('@google-cloud/nodejs-repo-tools');
const delay = require('delay');

const clientCmd = `node client.js`;
const serverCmd = `node server.js`;
Expand Down Expand Up @@ -71,10 +72,6 @@ const JWT_AUTH_TOKEN = jwt.sign(
{algorithm: 'RS256'}
);

const delay = mSec => {
return new Promise(resolve => setTimeout(resolve, mSec));
};

// API key
it(`should request a greeting from a remote Compute Engine instance using an API key`, async () => {
const output = await tools.runAsync(
Expand Down Expand Up @@ -136,14 +133,10 @@ it(`should request and handle a greeting locally using a JWT Auth Token`, async
});

// Misc
it('should require either an API key or a JWT Auth Token', done => {
tools.runAsync(`${clientCmd} -h ${GCE_HOST}`, cwd).then(
() => {},
error => {
assert.ok(
error.message.includes('One of API_KEY or JWT_AUTH_TOKEN must be set')
);
done();
}
it('should require either an API key or a JWT Auth Token', async () => {
const {stderr} = await tools.runAsyncWithIO(
`${clientCmd} -h ${GCE_HOST}`,
cwd
);
assert.ok(stderr.includes('One of API_KEY or JWT_AUTH_TOKEN must be set'));
});
2 changes: 1 addition & 1 deletion endpoints/getting-started/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// [START setup]
const express = require('express');
const bodyParser = require('body-parser');
const Buffer = require('safe-buffer').Buffer;
const {Buffer} = require('safe-buffer');

const app = express();

Expand Down
2 changes: 1 addition & 1 deletion endpoints/getting-started/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use strict';

const Buffer = require('safe-buffer').Buffer;
const {Buffer} = require('safe-buffer');
const express = require('express');
const path = require('path');
const proxyquire = require('proxyquire').noPreserveCache();
Expand Down

0 comments on commit 216006f

Please sign in to comment.