',
+ 'Lists gateways for a given device.',
{},
- async (opts) => {
+ async opts => {
const client = await getClient(opts.serviceAccount);
await listGatewaysForDevice(
client,
@@ -1901,46 +1902,46 @@ require(`yargs`) // eslint-disable-line
}
)
.example(
- `node $0 createDevice my-device my-registry RS256_X509_PEM ./rsa_cert.pem`
+ 'node $0 createDevice my-device my-registry RS256_X509_PEM ./rsa_cert.pem'
)
.example(
- `node $0 createEs256Device my-es-device my-registry ../ec_public.pem`
+ 'node $0 createEs256Device my-es-device my-registry ../ec_public.pem'
)
.example(
- `node $0 createRegistry my-registry my-iot-topic --serviceAccount=$secure/svc.json --projectId=my-project-id`
+ 'node $0 createRegistry my-registry my-iot-topic --serviceAccount=$secure/svc.json --projectId=my-project-id'
)
.example(
- `node $0 createRsa256Device my-rsa-device my-registry ../rsa_cert.pem`
+ 'node $0 createRsa256Device my-rsa-device my-registry ../rsa_cert.pem'
)
.example(
- `node $0 createGateway --registryId=my-registry --gatewayId=my-gateway\
- --format=RS256_X509_PEM --key=./rsa_cert.pem`
+ 'node $0 createGateway --registryId=my-registry --gatewayId=my-gateway\
+ --format=RS256_X509_PEM --key=./rsa_cert.pem'
)
- .example(`node $0 createUnauthDevice my-device my-registry`)
- .example(`node $0 deleteDevice my-device my-registry`)
- .example(`node $0 deleteRegistry my-device my-registry`)
- .example(`node $0 getDevice my-device my-registry`)
- .example(`node $0 getDeviceState my-device my-registry`)
- .example(`node $0 getIamPolicy my-registry`)
- .example(`node $0 getRegistry my-registry`)
+ .example('node $0 createUnauthDevice my-device my-registry')
+ .example('node $0 deleteDevice my-device my-registry')
+ .example('node $0 deleteRegistry my-device my-registry')
+ .example('node $0 getDevice my-device my-registry')
+ .example('node $0 getDeviceState my-device my-registry')
+ .example('node $0 getIamPolicy my-registry')
+ .example('node $0 getRegistry my-registry')
.example(
- `node $0 listDevices -s path/svc.json -p your-project-id -c asia-east1 my-registry`
+ 'node $0 listDevices -s path/svc.json -p your-project-id -c asia-east1 my-registry'
)
.example(
- `node $0 listRegistries -s path/svc.json -p your-project-id -c europe-west1`
+ 'node $0 listRegistries -s path/svc.json -p your-project-id -c europe-west1'
)
- .example(`node $0 patchRsa256 my-device my-registry ../rsa_cert.pem`)
- .example(`node $0 patchEs256 my-device my-registry ../ec_public.pem`)
- .example(`node $0 setConfig my-device my-registry "test" 0`)
- .example(`node $0 sendCommand my-device my-registry test`)
+ .example('node $0 patchRsa256 my-device my-registry ../rsa_cert.pem')
+ .example('node $0 patchEs256 my-device my-registry ../ec_public.pem')
+ .example('node $0 setConfig my-device my-registry "test" 0')
+ .example('node $0 sendCommand my-device my-registry test')
.example(
- `node $0 setIamPolicy my-registry user:example@example.com roles/viewer`
+ 'node $0 setIamPolicy my-registry user:example@example.com roles/viewer'
)
.example(
- `node $0 setupTopic my-iot-topic --serviceAccount=$HOME/creds_iot.json --projectId=my-project-id`
+ 'node $0 setupTopic my-iot-topic --serviceAccount=$HOME/creds_iot.json --projectId=my-project-id'
)
.wrap(120)
.recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/iot-core/docs`)
+ .epilogue('For more information, see https://cloud.google.com/iot-core/docs')
.help()
.strict().argv;
diff --git a/iot/manager/package.json b/iot/manager/package.json
index cd2708bafb..82aebe3a19 100644
--- a/iot/manager/package.json
+++ b/iot/manager/package.json
@@ -19,7 +19,7 @@
"dependencies": {
"@google-cloud/iot": "^2.0.0",
"@google-cloud/pubsub": "^2.0.0",
- "googleapis": "^61.0.0",
+ "googleapis": "^62.0.0",
"yargs": "^16.0.0"
},
"devDependencies": {
diff --git a/iot/manager/system-test/manager.test.js b/iot/manager/system-test/manager.test.js
index b28eb4fc8a..9f6418ccd5 100644
--- a/iot/manager/system-test/manager.test.js
+++ b/iot/manager/system-test/manager.test.js
@@ -44,11 +44,11 @@ before(async () => {
});
assert(
process.env.GOOGLE_CLOUD_PROJECT,
- `Must set GOOGLE_CLOUD_PROJECT environment variable!`
+ 'Must set GOOGLE_CLOUD_PROJECT environment variable!'
);
assert(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
- `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!`
+ 'Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!'
);
// Create a topic to be used for testing.
const [topic] = await pubSubClient.createTopic(topicName);
diff --git a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js
index 3df71cb130..ee35de1c28 100644
--- a/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js
+++ b/iot/mqtt_example/cloudiot_mqtt_example_nodejs.js
@@ -91,7 +91,7 @@ const publishAsync = (
// Publish "payload" to the MQTT topic. qos=1 means at least once delivery.
// Cloud IoT Core also supports qos=0 for at most once delivery.
console.log('Publishing message:', payload);
- client.publish(mqttTopic, payload, {qos: 1}, (err) => {
+ client.publish(mqttTopic, payload, {qos: 1}, err => {
if (!err) {
shouldBackoff = false;
backoffTime = MINIMUM_BACKOFF_TIME;
@@ -118,7 +118,7 @@ const publishAsync = (
client = mqtt.connect(connectionArgs);
// [END iot_mqtt_jwt_refresh]
- client.on('connect', (success) => {
+ client.on('connect', success => {
console.log('connect');
if (!success) {
console.log('Client not connected...');
@@ -139,7 +139,7 @@ const publishAsync = (
shouldBackoff = true;
});
- client.on('error', (err) => {
+ client.on('error', err => {
console.log('error', err);
});
@@ -230,7 +230,7 @@ const mqttDeviceDemo = (
// same as the device registry's Cloud Pub/Sub topic.
const mqttTopic = `/devices/${deviceId}/${messageType}`;
- client.on('connect', (success) => {
+ client.on('connect', success => {
console.log('connect');
if (!success) {
console.log('Client not connected...');
@@ -244,7 +244,7 @@ const mqttDeviceDemo = (
shouldBackoff = true;
});
- client.on('error', (err) => {
+ client.on('error', err => {
console.log('error', err);
});
@@ -280,7 +280,7 @@ const attachDevice = (deviceId, client, jwt) => {
attachPayload = `{ 'authorization' : ${jwt} }`;
}
- client.publish(attachTopic, attachPayload, {qos: 1}, (err) => {
+ client.publish(attachTopic, attachPayload, {qos: 1}, err => {
if (!err) {
shouldBackoff = false;
backoffTime = MINIMUM_BACKOFF_TIME;
@@ -301,7 +301,7 @@ const detachDevice = (deviceId, client, jwt) => {
detachPayload = `{ 'authorization' : ${jwt} }`;
}
- client.publish(detachTopic, detachPayload, {qos: 1}, (err) => {
+ client.publish(detachTopic, detachPayload, {qos: 1}, err => {
if (!err) {
shouldBackoff = false;
backoffTime = MINIMUM_BACKOFF_TIME;
@@ -361,7 +361,7 @@ const publishAsyncGateway = (
// Publish "payload" to the MQTT topic. qos=1 means at least once delivery.
// Cloud IoT Core also supports qos=0 for at most once delivery.
console.log(`Publishing message: ${payload} to ${mqttTopic}`);
- client.publish(mqttTopic, payload, {qos: 1}, (err) => {
+ client.publish(mqttTopic, payload, {qos: 1}, err => {
if (!err) {
shouldBackoff = false;
backoffTime = MINIMUM_BACKOFF_TIME;
@@ -440,7 +440,7 @@ const sendDataFromBoundDevice = (
const iatTime = parseInt(Date.now() / 1000);
const client = mqtt.connect(connectionArgs);
- client.on('connect', (success) => {
+ client.on('connect', success => {
if (!success) {
console.log('Client not connected...');
} else if (!publishChainInProgress) {
@@ -471,7 +471,7 @@ const sendDataFromBoundDevice = (
shouldBackoff = true;
});
- client.on('error', (err) => {
+ client.on('error', err => {
console.log('error', err);
});
@@ -528,7 +528,7 @@ const listenForConfigMessages = (
// Create a client, and connect to the Google MQTT bridge.
const client = mqtt.connect(connectionArgs);
- client.on('connect', (success) => {
+ client.on('connect', success => {
if (!success) {
console.log('Client not connected...');
} else {
@@ -554,7 +554,7 @@ const listenForConfigMessages = (
shouldBackoff = true;
});
- client.on('error', (err) => {
+ client.on('error', err => {
console.log('error', err);
});
@@ -615,7 +615,7 @@ const listenForErrorMessages = (
// Create a client, and connect to the Google MQTT bridge.
const client = mqtt.connect(connectionArgs);
- client.on('connect', (success) => {
+ client.on('connect', success => {
if (!success) {
console.log('Client not connected...');
} else {
@@ -638,7 +638,7 @@ const listenForErrorMessages = (
shouldBackoff = true;
});
- client.on('error', (err) => {
+ client.on('error', err => {
console.log('error', err);
});
@@ -654,10 +654,11 @@ const listenForErrorMessages = (
// [END iot_listen_for_error_messages]
};
-const {argv} = require(`yargs`)
+const {argv} = require('yargs')
.options({
projectId: {
- default: process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT,
+ default:
+ process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT,
description:
'The Project ID to use. Defaults to the value of the GOOGLE_CLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variables.',
requiresArg: true,
@@ -714,8 +715,8 @@ const {argv} = require(`yargs`)
},
})
.command(
- `mqttDeviceDemo`,
- `Connects a device, sends data, and receives data`,
+ 'mqttDeviceDemo',
+ 'Connects a device, sends data, and receives data',
{
messageType: {
default: 'events',
@@ -731,7 +732,7 @@ const {argv} = require(`yargs`)
type: 'number',
},
},
- (opts) => {
+ opts => {
mqttDeviceDemo(
opts.deviceId,
opts.registryId,
@@ -747,8 +748,8 @@ const {argv} = require(`yargs`)
}
)
.command(
- `sendDataFromBoundDevice`,
- `Sends data from a gateway on behalf of a bound device.`,
+ 'sendDataFromBoundDevice',
+ 'Sends data from a gateway on behalf of a bound device.',
{
gatewayId: {
description: 'Cloud IoT gateway ID.',
@@ -763,7 +764,7 @@ const {argv} = require(`yargs`)
type: 'number',
},
},
- (opts) => {
+ opts => {
sendDataFromBoundDevice(
opts.deviceId,
opts.gatewayId,
@@ -780,8 +781,8 @@ const {argv} = require(`yargs`)
}
)
.command(
- `listenForConfigMessages`,
- `Listens for configuration changes on a gateway and bound device.`,
+ 'listenForConfigMessages',
+ 'Listens for configuration changes on a gateway and bound device.',
{
gatewayId: {
description: 'Cloud IoT gateway ID.',
@@ -796,7 +797,7 @@ const {argv} = require(`yargs`)
type: 'number',
},
},
- (opts) => {
+ opts => {
listenForConfigMessages(
opts.deviceId,
opts.gatewayId,
@@ -812,8 +813,8 @@ const {argv} = require(`yargs`)
}
)
.command(
- `listenForErrorMessages`,
- `Listens for error messages on a gateway.`,
+ 'listenForErrorMessages',
+ 'Listens for error messages on a gateway.',
{
gatewayId: {
description: 'Cloud IoT gateway ID.',
@@ -828,7 +829,7 @@ const {argv} = require(`yargs`)
type: 'number',
},
},
- (opts) => {
+ opts => {
listenForErrorMessages(
opts.deviceId,
opts.gatewayId,
@@ -844,19 +845,19 @@ const {argv} = require(`yargs`)
}
)
.example(
- `node $0 mqttDeviceDemo --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --numMessages=10 \\\n`
+ 'node $0 mqttDeviceDemo --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --numMessages=10 \\\n'
)
.example(
- `node $0 sendDataFromBoundDevice --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n`
+ 'node $0 sendDataFromBoundDevice --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n'
)
.example(
- `node $0 listenForConfigMessages --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n\t--clientDuration=300000 \\\n`
+ 'node $0 listenForConfigMessages --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n\t--clientDuration=300000 \\\n'
)
.example(
- `node $0 listenForErrorMessages --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n\t--clientDuration=300000 \\\n`
+ 'node $0 listenForErrorMessages --projectId=blue-jet-123 \\\n\t--registryId=my-registry --deviceId=my-node-device \\\n\t--privateKeyFile=../rsa_private.pem --algorithm=RS256 \\\n\t--cloudRegion=us-central1 --gatewayId=my-node-gateway \\\n\t--clientDuration=300000 \\\n'
)
.wrap(120)
.recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/iot-core/docs`)
+ .epilogue('For more information, see https://cloud.google.com/iot-core/docs')
.help()
.strict();
diff --git a/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js b/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js
index bf7ff1cbc6..807ebbfd6e 100644
--- a/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js
+++ b/iot/mqtt_example/system-test/cloudiot_mqtt_example.test.js
@@ -26,7 +26,7 @@ const projectId =
process.env.GOOGLE_CLOUD_PROJECT || process.env.GOOGLE_CLOUD_PROJECT;
const topicName = `nodejs-iot-test-mqtt-topic-${uuid.v4()}`;
const registryName = `nodejs-iot-test-mqtt-registry-${uuid.v4()}`;
-const region = `us-central1`;
+const region = 'us-central1';
const rsaPublicCert = process.env.NODEJS_IOT_RSA_PUBLIC_CERT;
const rsaPrivateKey = process.env.NODEJS_IOT_RSA_PRIVATE_KEY;
@@ -45,11 +45,11 @@ assert.ok(
before(async () => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
- `Must set GOOGLE_CLOUD_PROJECT environment variable!`
+ 'Must set GOOGLE_CLOUD_PROJECT environment variable!'
);
assert(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
- `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!`
+ 'Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!'
);
// Create a unique topic to be used for testing.
const [topic] = await pubSubClient.createTopic(topicName);
@@ -205,8 +205,8 @@ it('should send state message', () => {
});
});
-it.only('should receive command message', async () => {
- const deviceId = `commands-device`;
+it('should receive command message', async () => {
+ const deviceId = 'commands-device';
const message = 'rotate 180 degrees';
childProcess.execSync(
@@ -239,7 +239,7 @@ it.only('should receive command message', async () => {
});
});
-it('should listen for bound device config message', () => {
+it.skip('should listen for bound device config message', () => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
childProcess.execSync(
`${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`,
@@ -276,7 +276,7 @@ it('should listen for bound device config message', () => {
});
});
-it('should listen for error topic messages', () => {
+it.skip('should listen for error topic messages', () => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
childProcess.execSync(
`${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`,
@@ -315,7 +315,7 @@ it('should listen for error topic messages', () => {
});
});
-it('should send data from bound device', async () => {
+it.skip('should send data from bound device', async () => {
const gatewayId = `nodejs-test-gateway-iot-${uuid.v4()}`;
childProcess.execSync(
`${helper} createGateway ${registryName} ${gatewayId} --publicKeyFormat=RSA_X509_PEM --publicKeyFile=${rsaPublicCert}`,
diff --git a/iot/scripts/iam.js b/iot/scripts/iam.js
index 779ff948e8..4a60ada5fd 100644
--- a/iot/scripts/iam.js
+++ b/iot/scripts/iam.js
@@ -19,7 +19,7 @@
* For more information, see https://cloud.google.com/iot.
*/
-const setTopicPolicy = async (topicName) => {
+const setTopicPolicy = async topicName => {
// Imports the Google Cloud client library
const {PubSub} = require('@google-cloud/pubsub');
@@ -44,7 +44,7 @@ const setTopicPolicy = async (topicName) => {
members: [serviceAccount],
};
- policy.bindings.forEach((_binding) => {
+ policy.bindings.forEach(_binding => {
if (_binding.role === binding.role) {
binding = _binding;
hasRole = true;
diff --git a/jobs/v3/auto-complete-sample.js b/jobs/v3/auto-complete-sample.js
index 161cba6a8a..32a20b3bba 100644
--- a/jobs/v3/auto-complete-sample.js
+++ b/jobs/v3/auto-complete-sample.js
@@ -14,8 +14,8 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
const createAuthCredential = require('./create-auth-credential');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
diff --git a/jobs/v3/basic-job-sample.js b/jobs/v3/basic-job-sample.js
index dccaf4c5f0..4c9c924e35 100644
--- a/jobs/v3/basic-job-sample.js
+++ b/jobs/v3/basic-job-sample.js
@@ -14,8 +14,8 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const createAuthCredential = require('./create-auth-credential');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
@@ -40,7 +40,7 @@ const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
/**
* Generate a basic job with given companyName.
*/
-const generateJobWithRequiredFields = (companyName) => {
+const generateJobWithRequiredFields = companyName => {
const applicationUris = ['http://careers.google.com'];
const description =
'Design, develop, test, deploy, maintain and improve software.';
@@ -79,7 +79,7 @@ const createJob = async (jobServiceClient, jobToBeCreated) => {
console.log(`Job created: ${JSON.stringify(jobCreated.data)}`);
return jobCreated.data;
} catch (e) {
- console.error(`Got exception while creating job!`);
+ console.error('Got exception while creating job!');
throw e;
}
};
@@ -126,7 +126,7 @@ const updateJob = async (jobServiceClient, jobName, jobToBeUpdated) => {
console.log(`Job updated: ${JSON.stringify(jobUpdated.data)}`);
return jobUpdated.data;
} catch (e) {
- console.error(`Got exception while updating job!`);
+ console.error('Got exception while updating job!');
throw e;
}
};
@@ -157,7 +157,7 @@ const updateJobWithFieldMask = async (
console.log(`Job updated: ${JSON.stringify(jobUpdated.data)}`);
return jobUpdated.data;
} catch (e) {
- console.error(`Got exception while updating job with field mask!`);
+ console.error('Got exception while updating job with field mask!');
throw e;
}
};
diff --git a/jobs/v3/batchdelete-jobs-sample.js b/jobs/v3/batchdelete-jobs-sample.js
index f35f5b45fd..8cf679cd13 100644
--- a/jobs/v3/batchdelete-jobs-sample.js
+++ b/jobs/v3/batchdelete-jobs-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const customAttributeSample = require('./custom-attribute-sample');
const sleep = require('./sleep');
@@ -36,7 +36,7 @@ const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
const batchDelete = async (jobServiceClient, companyName, jobs) => {
try {
let batchDeleteQuery = `companyName = "${companyName}"`;
- jobs.forEach((job) => {
+ jobs.forEach(job => {
batchDeleteQuery += ` AND requisitionId = "${job.requisitionId}"`;
});
diff --git a/jobs/v3/commute-search-sample.js b/jobs/v3/commute-search-sample.js
index 3f600fca85..cc1c349655 100644
--- a/jobs/v3/commute-search-sample.js
+++ b/jobs/v3/commute-search-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
diff --git a/jobs/v3/custom-attribute-sample.js b/jobs/v3/custom-attribute-sample.js
index c4b35b206d..4cbcd67f16 100644
--- a/jobs/v3/custom-attribute-sample.js
+++ b/jobs/v3/custom-attribute-sample.js
@@ -14,8 +14,8 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
@@ -39,7 +39,7 @@ const REQUEST_META_DATA = {
/**
* Generate a job with a custom attribute.
*/
-const generateJobWithACustomAttribute = (companyName) => {
+const generateJobWithACustomAttribute = companyName => {
const requisitionId = `jobWithACustomAttribute: ${new Date().getTime()}`;
const jobTitle = 'Software Engineer';
const applicationUrls = ['http://careers.google.com'];
@@ -70,7 +70,7 @@ const generateJobWithACustomAttribute = (companyName) => {
/**
* CustomAttributeFilter on String value CustomAttribute
*/
-const filtersOnStringValueCustomAttribute = async (jobServiceClient) => {
+const filtersOnStringValueCustomAttribute = async jobServiceClient => {
try {
const customAttributeFilter = 'NOT EMPTY(someFieldName1)';
const jobQuery = {customAttributeFilter: customAttributeFilter};
@@ -97,7 +97,7 @@ const filtersOnStringValueCustomAttribute = async (jobServiceClient) => {
/**
* CustomAttributeFilter on Long value CustomAttribute
*/
-const filtersOnLongValueCustomAttribute = async (jobServiceClient) => {
+const filtersOnLongValueCustomAttribute = async jobServiceClient => {
try {
const customAttributeFilter =
'(255 <= someFieldName2) AND' + ' (someFieldName2 <= 257)';
@@ -125,7 +125,7 @@ const filtersOnLongValueCustomAttribute = async (jobServiceClient) => {
/**
* CustomAttributeFilter on multiple CustomAttributes
*/
-const filtersOnMultiCustomAttributes = async (jobServiceClient) => {
+const filtersOnMultiCustomAttributes = async jobServiceClient => {
try {
const customAttributeFilter =
'(someFieldName1 = "value1") AND ((255 <= someFieldName2) OR ' +
diff --git a/jobs/v3/email-alert-search-sample.js b/jobs/v3/email-alert-search-sample.js
index aab2b36d6e..91b78e4c1d 100644
--- a/jobs/v3/email-alert-search-sample.js
+++ b/jobs/v3/email-alert-search-sample.js
@@ -14,8 +14,8 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
diff --git a/jobs/v3/featured-job-search-sample.js b/jobs/v3/featured-job-search-sample.js
index 5d84052aef..3237d30f8d 100644
--- a/jobs/v3/featured-job-search-sample.js
+++ b/jobs/v3/featured-job-search-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
@@ -34,7 +34,7 @@ const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
/**
* Creates a job as featured.
*/
-const generateFeaturedJob = (companyName) => {
+const generateFeaturedJob = companyName => {
const requisitionId = `"featuredJob: ${new Date().getTime()}}`;
const jobTitle = 'Software Engineer';
const applicationUrls = ['http://careers.google.com'];
diff --git a/jobs/v3/general-search-sample.js b/jobs/v3/general-search-sample.js
index fe5d487a27..dc6e5388f4 100644
--- a/jobs/v3/general-search-sample.js
+++ b/jobs/v3/general-search-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
diff --git a/jobs/v3/histogram-sample.js b/jobs/v3/histogram-sample.js
index 1169707484..50cfa54baa 100644
--- a/jobs/v3/histogram-sample.js
+++ b/jobs/v3/histogram-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const customAttributeSample = require('./custom-attribute-sample');
const sleep = require('./sleep');
@@ -40,7 +40,7 @@ const histogramSearch = async (jobServiceClient, companyName) => {
};
const customAttributeHistogramFacet = {
- key: `someFieldName1`,
+ key: 'someFieldName1',
stringValueHistogram: true,
};
diff --git a/jobs/v3/location-search-sample.js b/jobs/v3/location-search-sample.js
index 34df024acd..6a20ea41f9 100644
--- a/jobs/v3/location-search-sample.js
+++ b/jobs/v3/location-search-sample.js
@@ -14,9 +14,9 @@
'use strict';
-const basicCompanySample = require(`./basic-company-sample`);
-const basicJobSample = require(`./basic-job-sample`);
-const createAuthCredential = require(`./create-auth-credential`);
+const basicCompanySample = require('./basic-company-sample');
+const basicJobSample = require('./basic-job-sample');
+const createAuthCredential = require('./create-auth-credential');
const sleep = require('./sleep');
const PROJECT_ID = process.env.GOOGLE_CLOUD_PROJECT;
diff --git a/jobs/v3/package.json b/jobs/v3/package.json
index e2e198d0f4..5a3e888fc6 100644
--- a/jobs/v3/package.json
+++ b/jobs/v3/package.json
@@ -16,7 +16,7 @@
"system-test": "mocha system-test/*.test.js --timeout=40000"
},
"dependencies": {
- "googleapis": "^61.0.0",
+ "googleapis": "^62.0.0",
"uuid": "^8.0.0",
"yargs": "^16.0.0"
},
diff --git a/jobs/v3/quickstart.js b/jobs/v3/quickstart.js
index b5cfb20b00..33befbde9c 100755
--- a/jobs/v3/quickstart.js
+++ b/jobs/v3/quickstart.js
@@ -58,9 +58,9 @@ google.auth.getApplicationDefault((err, authClient) => {
if (companies.length) {
console.log('Companies:');
- companies.forEach((company) => console.log(company.name));
+ companies.forEach(company => console.log(company.name));
} else {
- console.log(`No companies found.`);
+ console.log('No companies found.');
}
});
});
diff --git a/jobs/v3/sleep.js b/jobs/v3/sleep.js
index d7bbb893c3..531a29619b 100644
--- a/jobs/v3/sleep.js
+++ b/jobs/v3/sleep.js
@@ -14,8 +14,8 @@
'use strict';
-const sleep = (ms) => {
- return new Promise((resolve) => setTimeout(resolve, ms));
+const sleep = ms => {
+ return new Promise(resolve => setTimeout(resolve, ms));
};
module.exports = sleep;
diff --git a/jobs/v3/system-test/basic-company-sample.test.js b/jobs/v3/system-test/basic-company-sample.test.js
index b5c0d62082..3686eaba45 100644
--- a/jobs/v3/system-test/basic-company-sample.test.js
+++ b/jobs/v3/system-test/basic-company-sample.test.js
@@ -16,7 +16,7 @@
const assert = require('assert');
const {execSync} = require('child_process');
-const runSample = `require('./basic-company-sample').runSample()`;
+const runSample = "require('./basic-company-sample').runSample()";
it('Should create a company, get a company, update a company, update a company with field mask and delete a company', () => {
const output = execSync(`node -e ${runSample}`);
diff --git a/jobs/v3/system-test/basic-job-sample.test.js b/jobs/v3/system-test/basic-job-sample.test.js
index c13aea0ba8..0f28ad0e10 100644
--- a/jobs/v3/system-test/basic-job-sample.test.js
+++ b/jobs/v3/system-test/basic-job-sample.test.js
@@ -14,19 +14,19 @@
'use strict';
-const assert = require(`assert`);
+const assert = require('assert');
const {execSync} = require('child_process');
-const runSample = `require('./basic-job-sample').runSample()`;
+const runSample = "require('./basic-job-sample').runSample()";
-it(`Should create a job, get a job, update a job, update a job with field mask, and delete a job`, () => {
+it('Should create a job, get a job, update a job, update a job with field mask, and delete a job', () => {
const output = execSync(`node -e ${runSample}`);
const pattern =
- `.*Job generated:.*\n` +
- `.*Job created:.*\n` +
- `.*Job existed:.*\n` +
- `.*Job updated:.*changedDescription.*\n` +
- `.*Job updated:.*changedJobTitle.*\n` +
- `.*Job deleted.*`;
+ '.*Job generated:.*\n' +
+ '.*Job created:.*\n' +
+ '.*Job existed:.*\n' +
+ '.*Job updated:.*changedDescription.*\n' +
+ '.*Job updated:.*changedJobTitle.*\n' +
+ '.*Job deleted.*';
assert.strictEqual(new RegExp(pattern).test(output), true);
});
diff --git a/jobs/v3/system-test/batchdelete-jobs-sample.test.js b/jobs/v3/system-test/batchdelete-jobs-sample.test.js
index 6f8cd11b1a..40eb9d0305 100644
--- a/jobs/v3/system-test/batchdelete-jobs-sample.test.js
+++ b/jobs/v3/system-test/batchdelete-jobs-sample.test.js
@@ -16,7 +16,7 @@
const assert = require('assert');
const {execSync} = require('child_process');
-const runSample = `require('./batchdelete-jobs-sample')`;
+const runSample = "require('./batchdelete-jobs-sample')";
it('Should batchDelete jobs.', () => {
const output = execSync(`node -e ${runSample}`);
diff --git a/jobs/v3/system-test/custom-attribute-sample.test.js b/jobs/v3/system-test/custom-attribute-sample.test.js
index c2c2c787c9..40c1e21a56 100644
--- a/jobs/v3/system-test/custom-attribute-sample.test.js
+++ b/jobs/v3/system-test/custom-attribute-sample.test.js
@@ -16,7 +16,7 @@
const assert = require('assert');
const {execSync} = require('child_process');
-const runSample = `require('./custom-attribute-sample').runSample()`;
+const runSample = "require('./custom-attribute-sample').runSample()";
it('should search job with custom attribute filter', () => {
const output = execSync(`node -e ${runSample}`);
diff --git a/jobs/v4/job_search_autocomplete_job_title.js b/jobs/v4/job_search_autocomplete_job_title.js
index 020fc540a2..5873dd0cc9 100644
--- a/jobs/v4/job_search_autocomplete_job_title.js
+++ b/jobs/v4/job_search_autocomplete_job_title.js
@@ -12,7 +12,13 @@ const talent = require('@google-cloud/talent').v4beta1;
* @param projectId {string} Your Google Cloud Project ID
* @param tenantId {string} Identifier of the Tenantd
*/
-function sampleCompleteQuery(projectId, tenantId, query, numResults, languageCode) {
+function sampleCompleteQuery(
+ projectId,
+ tenantId,
+ query,
+ numResults,
+ languageCode
+) {
const client = new talent.CompletionClient();
// const projectId = 'Your Google Cloud Project ID';
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
@@ -27,7 +33,8 @@ function sampleCompleteQuery(projectId, tenantId, query, numResults, languageCod
pageSize: numResults,
languageCodes: languageCodes,
};
- client.completeQuery(request)
+ client
+ .completeQuery(request)
.then(responses => {
const response = responses[0];
for (const result of response.completionResults) {
@@ -41,32 +48,36 @@ function sampleCompleteQuery(projectId, tenantId, query, numResults, languageCod
});
}
-
// [END job_search_autocomplete_job_title_core]
// [END job_search_autocomplete_job_title]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('query', {
default: '[partially typed job title]',
- string: true
+ string: true,
})
.option('num_results', {
default: 5,
- number: true
+ number: true,
})
.option('language_code', {
default: 'en-US',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCompleteQuery(argv.project_id, argv.tenant_id, argv.query, argv.num_results, argv.language_code);
\ No newline at end of file
+sampleCompleteQuery(
+ argv.project_id,
+ argv.tenant_id,
+ argv.query,
+ argv.num_results,
+ argv.language_code
+);
diff --git a/jobs/v4/job_search_batch_delete_job.js b/jobs/v4/job_search_batch_delete_job.js
index 926ca37def..5dd6880ac7 100644
--- a/jobs/v4/job_search_batch_delete_job.js
+++ b/jobs/v4/job_search_batch_delete_job.js
@@ -28,27 +28,25 @@ function sampleBatchDeleteJobs(projectId, tenantId, filter) {
client.batchDeleteJobs(request).catch(err => {
console.error(err);
});
- console.log(`Batch deleted jobs from filter`);
+ console.log('Batch deleted jobs from filter');
}
-
// [END job_search_batch_delete_job_core]
// [END job_search_batch_delete_job]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('filter', {
default: '[Query]',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleBatchDeleteJobs(argv.project_id, argv.tenant_id, argv.filter);
\ No newline at end of file
+sampleBatchDeleteJobs(argv.project_id, argv.tenant_id, argv.filter);
diff --git a/jobs/v4/job_search_commute_search.js b/jobs/v4/job_search_commute_search.js
index 3693a5c2c2..e8bceee4ab 100644
--- a/jobs/v4/job_search_commute_search.js
+++ b/jobs/v4/job_search_commute_search.js
@@ -46,7 +46,8 @@ function sampleSearchJobs(projectId, tenantId) {
jobQuery: jobQuery,
};
- client.searchJobs(request)
+ client
+ .searchJobs(request)
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -62,20 +63,18 @@ function sampleSearchJobs(projectId, tenantId) {
});
}
-
// [END job_search_commute_search_core]
// [END job_search_commute_search]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleSearchJobs(argv.project_id, argv.tenant_id);
\ No newline at end of file
+sampleSearchJobs(argv.project_id, argv.tenant_id);
diff --git a/jobs/v4/job_search_create_client_event.js b/jobs/v4/job_search_create_client_event.js
index 78145d8b4f..18ed7d3551 100644
--- a/jobs/v4/job_search_create_client_event.js
+++ b/jobs/v4/job_search_create_client_event.js
@@ -36,7 +36,8 @@ function sampleCreateClientEvent(projectId, tenantId, requestId, eventId) {
// List of job names associated with this event
const jobsElement = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]';
- const jobsElement2 = 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]';
+ const jobsElement2 =
+ 'projects/[Project ID]/tenants/[Tenant ID]/jobs/[Job ID]';
const jobs = [jobsElement, jobsElement2];
const jobEvent = {
type: type,
@@ -52,38 +53,42 @@ function sampleCreateClientEvent(projectId, tenantId, requestId, eventId) {
parent: formattedParent,
clientEvent: clientEvent,
};
- client.createClientEvent(request)
+ client
+ .createClientEvent(request)
.then(responses => {
const response = responses[0];
- console.log(`Created client event`);
+ console.log('Created client event');
})
.catch(err => {
console.error(err);
});
}
-
// [END job_search_create_client_event_core]
// [END job_search_create_client_event]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('request_id', {
default: '[request_id from ResponseMetadata]',
- string: true
+ string: true,
})
.option('event_id', {
default: '[Set this to a unique identifier]',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCreateClientEvent(argv.project_id, argv.tenant_id, argv.request_id, argv.event_id);
\ No newline at end of file
+sampleCreateClientEvent(
+ argv.project_id,
+ argv.tenant_id,
+ argv.request_id,
+ argv.event_id
+);
diff --git a/jobs/v4/job_search_create_company.js b/jobs/v4/job_search_create_company.js
index fd4af2e9d5..2ad9eae3af 100644
--- a/jobs/v4/job_search_create_company.js
+++ b/jobs/v4/job_search_create_company.js
@@ -27,10 +27,11 @@ function sampleCreateCompany(projectId, tenantId, displayName, externalId) {
parent: formattedParent,
company: company,
};
- client.createCompany(request)
+ client
+ .createCompany(request)
.then(responses => {
const response = responses[0];
- console.log(`Created Company`);
+ console.log('Created Company');
console.log(`Name: ${response.name}`);
console.log(`Display Name: ${response.displayName}`);
console.log(`External ID: ${response.externalId}`);
@@ -40,28 +41,31 @@ function sampleCreateCompany(projectId, tenantId, displayName, externalId) {
});
}
-
// [END job_search_create_company_core]
// [END job_search_create_company]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('display_name', {
default: 'My Company Name',
- string: true
+ string: true,
})
.option('external_id', {
default: 'Identifier of this company in my system',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCreateCompany(argv.project_id, argv.tenant_id, argv.display_name, argv.external_id);
\ No newline at end of file
+sampleCreateCompany(
+ argv.project_id,
+ argv.tenant_id,
+ argv.display_name,
+ argv.external_id
+);
diff --git a/jobs/v4/job_search_create_job.js b/jobs/v4/job_search_create_job.js
index 7f7ffb39a8..c0d33e3ae3 100644
--- a/jobs/v4/job_search_create_job.js
+++ b/jobs/v4/job_search_create_job.js
@@ -12,7 +12,18 @@ const talent = require('@google-cloud/talent').v4beta1;
* @param projectId {string} Your Google Cloud Project ID
* @param tenantId {string} Identifier of the Tenant
*/
-function sampleCreateJob(projectId, tenantId, companyName, requisitionId, title, description, jobApplicationUrl, addressOne, addressTwo, languageCode) {
+function sampleCreateJob(
+ projectId,
+ tenantId,
+ companyName,
+ requisitionId,
+ title,
+ description,
+ jobApplicationUrl,
+ addressOne,
+ addressTwo,
+ languageCode
+) {
const client = new talent.JobServiceClient();
// const projectId = 'Your Google Cloud Project ID';
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
@@ -43,7 +54,8 @@ function sampleCreateJob(projectId, tenantId, companyName, requisitionId, title,
parent: formattedParent,
job: job,
};
- client.createJob(request)
+ client
+ .createJob(request)
.then(responses => {
const response = responses[0];
console.log(`Created job: ${response.name}`);
@@ -53,52 +65,61 @@ function sampleCreateJob(projectId, tenantId, companyName, requisitionId, title,
});
}
-
// [END job_search_create_job_core]
// [END job_search_create_job]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('company_name', {
default: 'Company name, e.g. projects/your-project/companies/company-id',
- string: true
+ string: true,
})
.option('requisition_id', {
default: 'Job requisition ID, aka Posting ID. Unique per job.',
- string: true
+ string: true,
})
.option('title', {
default: 'Software Engineer',
- string: true
+ string: true,
})
.option('description', {
default: 'This is a description of this wonderful job!',
- string: true
+ string: true,
})
.option('job_application_url', {
default: 'https://www.example.org/job-posting/123',
- string: true
+ string: true,
})
.option('address_one', {
default: '1600 Amphitheatre Parkway, Mountain View, CA 94043',
- string: true
+ string: true,
})
.option('address_two', {
default: '111 8th Avenue, New York, NY 10011',
- string: true
+ string: true,
})
.option('language_code', {
default: 'en-US',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCreateJob(argv.project_id, argv.tenant_id, argv.company_name, argv.requisition_id, argv.title, argv.description, argv.job_application_url, argv.address_one, argv.address_two, argv.language_code);
\ No newline at end of file
+sampleCreateJob(
+ argv.project_id,
+ argv.tenant_id,
+ argv.company_name,
+ argv.requisition_id,
+ argv.title,
+ argv.description,
+ argv.job_application_url,
+ argv.address_one,
+ argv.address_two,
+ argv.language_code
+);
diff --git a/jobs/v4/job_search_create_job_custom_attributes.js b/jobs/v4/job_search_create_job_custom_attributes.js
index a4bd9a94fe..bccfed9329 100644
--- a/jobs/v4/job_search_create_job_custom_attributes.js
+++ b/jobs/v4/job_search_create_job_custom_attributes.js
@@ -12,7 +12,13 @@ const talent = require('@google-cloud/talent').v4beta1;
* @param projectId {string} Your Google Cloud Project ID
* @param tenantId {string} Identifier of the Tenantd
*/
-function sampleCreateJob(projectId, tenantId, companyName, requisitionId, languageCode) {
+function sampleCreateJob(
+ projectId,
+ tenantId,
+ companyName,
+ requisitionId,
+ languageCode
+) {
const client = new talent.JobServiceClient();
// const projectId = 'Your Google Cloud Project ID';
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
@@ -29,7 +35,8 @@ function sampleCreateJob(projectId, tenantId, companyName, requisitionId, langua
parent: formattedParent,
job: job,
};
- client.createJob(request)
+ client
+ .createJob(request)
.then(responses => {
const response = responses[0];
console.log(`Created job: ${response.name}`);
@@ -39,32 +46,36 @@ function sampleCreateJob(projectId, tenantId, companyName, requisitionId, langua
});
}
-
// [END job_search_create_job_custom_attributes_core]
// [END job_search_create_job_custom_attributes]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('company_name', {
default: 'Company name, e.g. projects/your-project/companies/company-id',
- string: true
+ string: true,
})
.option('requisition_id', {
default: 'Job requisition ID, aka Posting ID. Unique per job.',
- string: true
+ string: true,
})
.option('language_code', {
default: 'en-US',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCreateJob(argv.project_id, argv.tenant_id, argv.company_name, argv.requisition_id, argv.language_code);
\ No newline at end of file
+sampleCreateJob(
+ argv.project_id,
+ argv.tenant_id,
+ argv.company_name,
+ argv.requisition_id,
+ argv.language_code
+);
diff --git a/jobs/v4/job_search_create_tenant.js b/jobs/v4/job_search_create_tenant.js
index 18326d4c67..f300997079 100644
--- a/jobs/v4/job_search_create_tenant.js
+++ b/jobs/v4/job_search_create_tenant.js
@@ -19,10 +19,11 @@ function sampleCreateTenant(projectId, externalId) {
parent: formattedParent,
tenant: tenant,
};
- client.createTenant(request)
+ client
+ .createTenant(request)
.then(responses => {
const response = responses[0];
- console.log(`Created Tenant`);
+ console.log('Created Tenant');
console.log(`Name: ${response.name}`);
console.log(`External ID: ${response.externalId}`);
})
@@ -31,20 +32,18 @@ function sampleCreateTenant(projectId, externalId) {
});
}
-
// [END job_search_create_tenant_core]
// [END job_search_create_tenant]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('external_id', {
default: 'Your Unique Identifier for Tenant',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleCreateTenant(argv.project_id, argv.external_id);
\ No newline at end of file
+sampleCreateTenant(argv.project_id, argv.external_id);
diff --git a/jobs/v4/job_search_custom_ranking_search.js b/jobs/v4/job_search_custom_ranking_search.js
index eea6ce7b76..f0b207abf0 100644
--- a/jobs/v4/job_search_custom_ranking_search.js
+++ b/jobs/v4/job_search_custom_ranking_search.js
@@ -40,7 +40,8 @@ function sampleSearchJobs(projectId, tenantId) {
orderBy: orderBy,
};
- client.searchJobs(request)
+ client
+ .searchJobs(request)
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -56,20 +57,18 @@ function sampleSearchJobs(projectId, tenantId) {
});
}
-
// [END job_search_custom_ranking_search_core]
// [END job_search_custom_ranking_search]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleSearchJobs(argv.project_id, argv.tenant_id);
\ No newline at end of file
+sampleSearchJobs(argv.project_id, argv.tenant_id);
diff --git a/jobs/v4/job_search_delete_company.js b/jobs/v4/job_search_delete_company.js
index ba2b8699b8..a2f492c100 100644
--- a/jobs/v4/job_search_delete_company.js
+++ b/jobs/v4/job_search_delete_company.js
@@ -16,27 +16,25 @@ function sampleDeleteCompany(projectId, tenantId, companyId) {
client.deleteCompany({name: formattedName}).catch(err => {
console.error(err);
});
- console.log(`Deleted company`);
+ console.log('Deleted company');
}
-
// [END job_search_delete_company_core]
// [END job_search_delete_company]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('company_id', {
default: 'ID of the company to delete',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleDeleteCompany(argv.project_id, argv.tenant_id, argv.company_id);
\ No newline at end of file
+sampleDeleteCompany(argv.project_id, argv.tenant_id, argv.company_id);
diff --git a/jobs/v4/job_search_delete_job.js b/jobs/v4/job_search_delete_job.js
index 6046e72cdd..f34004a0aa 100644
--- a/jobs/v4/job_search_delete_job.js
+++ b/jobs/v4/job_search_delete_job.js
@@ -16,27 +16,25 @@ function sampleDeleteJob(projectId, tenantId, jobId) {
client.deleteJob({name: formattedName}).catch(err => {
console.error(err);
});
- console.log(`Deleted job.`);
+ console.log('Deleted job.');
}
-
// [END job_search_delete_job_core]
// [END job_search_delete_job]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('job_id', {
default: 'Company ID',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleDeleteJob(argv.project_id, argv.tenant_id, argv.job_id);
\ No newline at end of file
+sampleDeleteJob(argv.project_id, argv.tenant_id, argv.job_id);
diff --git a/jobs/v4/job_search_delete_tenant.js b/jobs/v4/job_search_delete_tenant.js
index 17d3904c54..162fd20784 100644
--- a/jobs/v4/job_search_delete_tenant.js
+++ b/jobs/v4/job_search_delete_tenant.js
@@ -15,23 +15,21 @@ function sampleDeleteTenant(projectId, tenantId) {
client.deleteTenant({name: formattedName}).catch(err => {
console.error(err);
});
- console.log(`Deleted Tenant.`);
+ console.log('Deleted Tenant.');
}
-
// [END job_search_delete_tenant_core]
// [END job_search_delete_tenant]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID)',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleDeleteTenant(argv.project_id, argv.tenant_id);
\ No newline at end of file
+sampleDeleteTenant(argv.project_id, argv.tenant_id);
diff --git a/jobs/v4/job_search_get_company.js b/jobs/v4/job_search_get_company.js
index c6be75e6f4..359895ddd9 100644
--- a/jobs/v4/job_search_get_company.js
+++ b/jobs/v4/job_search_get_company.js
@@ -13,7 +13,8 @@ function sampleGetCompany(projectId, tenantId, companyId) {
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
// const companyId = 'Company ID';
const formattedName = client.companyPath(projectId, tenantId, companyId);
- client.getCompany({name: formattedName})
+ client
+ .getCompany({name: formattedName})
.then(responses => {
const response = responses[0];
console.log(`Company name: ${response.name}`);
@@ -24,24 +25,22 @@ function sampleGetCompany(projectId, tenantId, companyId) {
});
}
-
// [END job_search_get_company_core]
// [END job_search_get_company]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('company_id', {
default: 'Company ID',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleGetCompany(argv.project_id, argv.tenant_id, argv.company_id);
\ No newline at end of file
+sampleGetCompany(argv.project_id, argv.tenant_id, argv.company_id);
diff --git a/jobs/v4/job_search_get_job.js b/jobs/v4/job_search_get_job.js
index 4eb69a140a..803c969a1e 100644
--- a/jobs/v4/job_search_get_job.js
+++ b/jobs/v4/job_search_get_job.js
@@ -13,7 +13,8 @@ function sampleGetJob(projectId, tenantId, jobId) {
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
// const jobId = 'Job ID';
const formattedName = client.jobPath(projectId, tenantId, jobId);
- client.getJob({name: formattedName})
+ client
+ .getJob({name: formattedName})
.then(responses => {
const response = responses[0];
console.log(`Job name: ${response.name}`);
@@ -36,24 +37,22 @@ function sampleGetJob(projectId, tenantId, jobId) {
});
}
-
// [END job_search_get_job_core]
// [END job_search_get_job]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('job_id', {
default: 'Job ID',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleGetJob(argv.project_id, argv.tenant_id, argv.job_id);
\ No newline at end of file
+sampleGetJob(argv.project_id, argv.tenant_id, argv.job_id);
diff --git a/jobs/v4/job_search_get_tenant.js b/jobs/v4/job_search_get_tenant.js
index a182cec7f8..42d30f5360 100644
--- a/jobs/v4/job_search_get_tenant.js
+++ b/jobs/v4/job_search_get_tenant.js
@@ -12,7 +12,8 @@ function sampleGetTenant(projectId, tenantId) {
// const projectId = 'Your Google Cloud Project ID';
// const tenantId = 'Your Tenant ID';
const formattedName = client.tenantPath(projectId, tenantId);
- client.getTenant({name: formattedName})
+ client
+ .getTenant({name: formattedName})
.then(responses => {
const response = responses[0];
console.log(`Name: ${response.name}`);
@@ -23,20 +24,18 @@ function sampleGetTenant(projectId, tenantId) {
});
}
-
// [END job_search_get_tenant_core]
// [END job_search_get_tenant]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleGetTenant(argv.project_id, argv.tenant_id);
\ No newline at end of file
+sampleGetTenant(argv.project_id, argv.tenant_id);
diff --git a/jobs/v4/job_search_histogram_search.js b/jobs/v4/job_search_histogram_search.js
index 8ef7b4b628..315c48d102 100644
--- a/jobs/v4/job_search_histogram_search.js
+++ b/jobs/v4/job_search_histogram_search.js
@@ -38,7 +38,8 @@ function sampleSearchJobs(projectId, tenantId, query) {
histogramQueries: histogramQueries,
};
- client.searchJobs(request)
+ client
+ .searchJobs(request)
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -54,24 +55,22 @@ function sampleSearchJobs(projectId, tenantId, query) {
});
}
-
// [END job_search_histogram_search_core]
// [END job_search_histogram_search]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('query', {
default: 'count(base_compensation, [bucket(12, 20)])',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleSearchJobs(argv.project_id, argv.tenant_id, argv.query);
\ No newline at end of file
+sampleSearchJobs(argv.project_id, argv.tenant_id, argv.query);
diff --git a/jobs/v4/job_search_list_companies.js b/jobs/v4/job_search_list_companies.js
index 1b5d9cef46..cb74563b28 100644
--- a/jobs/v4/job_search_list_companies.js
+++ b/jobs/v4/job_search_list_companies.js
@@ -19,7 +19,8 @@ function sampleListCompanies(projectId, tenantId) {
// const tenantId = 'Your Tenant ID (using tenancy is optional)';
const formattedParent = client.tenantPath(projectId, tenantId);
- client.listCompanies({parent: formattedParent})
+ client
+ .listCompanies({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -33,20 +34,18 @@ function sampleListCompanies(projectId, tenantId) {
});
}
-
// [END job_search_list_companies_core]
// [END job_search_list_companies]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleListCompanies(argv.project_id, argv.tenant_id);
\ No newline at end of file
+sampleListCompanies(argv.project_id, argv.tenant_id);
diff --git a/jobs/v4/job_search_list_jobs.js b/jobs/v4/job_search_list_jobs.js
index 22b656c1fe..7c8df41abc 100644
--- a/jobs/v4/job_search_list_jobs.js
+++ b/jobs/v4/job_search_list_jobs.js
@@ -24,7 +24,8 @@ function sampleListJobs(projectId, tenantId, filter) {
filter: filter,
};
- client.listJobs(request)
+ client
+ .listJobs(request)
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -39,24 +40,22 @@ function sampleListJobs(projectId, tenantId, filter) {
});
}
-
// [END job_search_list_jobs_core]
// [END job_search_list_jobs]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
+const argv = require('yargs')
.option('project_id', {
default: 'Your Google Cloud Project ID',
- string: true
+ string: true,
})
.option('tenant_id', {
default: 'Your Tenant ID (using tenancy is optional)',
- string: true
+ string: true,
})
.option('filter', {
default: 'companyName=projects/my-project/companies/company-id',
- string: true
- })
- .argv;
+ string: true,
+ }).argv;
-sampleListJobs(argv.project_id, argv.tenant_id, argv.filter);
\ No newline at end of file
+sampleListJobs(argv.project_id, argv.tenant_id, argv.filter);
diff --git a/jobs/v4/job_search_list_tenants.js b/jobs/v4/job_search_list_tenants.js
index 546a295fc1..7316417413 100644
--- a/jobs/v4/job_search_list_tenants.js
+++ b/jobs/v4/job_search_list_tenants.js
@@ -13,7 +13,8 @@ function sampleListTenants(projectId) {
// const projectId = 'Your Google Cloud Project ID';
const formattedParent = client.projectPath(projectId);
- client.listTenants({parent: formattedParent})
+ client
+ .listTenants({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
@@ -26,16 +27,13 @@ function sampleListTenants(projectId) {
});
}
-
// [END job_search_list_tenants_core]
// [END job_search_list_tenants]
// tslint:disable-next-line:no-any
-const argv = require(`yargs`)
- .option('project_id', {
- default: 'Your Google Cloud Project ID',
- string: true
- })
- .argv;
+const argv = require('yargs').option('project_id', {
+ default: 'Your Google Cloud Project ID',
+ string: true,
+}).argv;
-sampleListTenants(argv.project_id);
\ No newline at end of file
+sampleListTenants(argv.project_id);
diff --git a/memorystore/redis/server.js b/memorystore/redis/server.js
index 5e5f24bd8e..0aff1a06dc 100644
--- a/memorystore/redis/server.js
+++ b/memorystore/redis/server.js
@@ -21,7 +21,7 @@ const REDISHOST = process.env.REDISHOST || 'localhost';
const REDISPORT = process.env.REDISPORT || 6379;
const client = redis.createClient(REDISPORT, REDISHOST);
-client.on('error', (err) => console.error('ERR:REDIS:', err));
+client.on('error', err => console.error('ERR:REDIS:', err));
// create a server
http
diff --git a/package.json b/package.json
index d2a0e3952d..aadd92ff03 100644
--- a/package.json
+++ b/package.json
@@ -13,18 +13,12 @@
},
"private": true,
"scripts": {
- "lint": "eslint '**/*.js'",
- "fix": "eslint --fix '**/*.js'",
+ "lint": "gts check",
+ "fix": "gts fix",
"test": "echo 'Please run tests in each sample directory.' && exit 1"
},
"devDependencies": {
- "eslint": "^7.0.0",
- "eslint-config-prettier": "^6.0.0",
- "eslint-plugin-node": "^11.0.0",
- "eslint-plugin-prettier": "^3.1.0",
- "eslint-plugin-promise": "^4.1.1",
"gts": "^3.0.0",
- "prettier": "^2.0.0",
"requestretry": "^4.0.0",
"typescript": "^4.0.0"
}
diff --git a/run/hello-broken/test/system.test.js b/run/hello-broken/test/system.test.js
index 1de85e64fe..0f43eb6546 100644
--- a/run/hello-broken/test/system.test.js
+++ b/run/hello-broken/test/system.test.js
@@ -62,8 +62,8 @@ describe('End-to-End Tests', () => {
);
assert.strictEqual(
response.body,
- `Hello World!`,
- `Expected fallback "World" not found`
+ 'Hello World!',
+ 'Expected fallback "World" not found'
);
});
});
diff --git a/run/helloworld/package.json b/run/helloworld/package.json
index 2b9bbd7773..11f958a3b6 100644
--- a/run/helloworld/package.json
+++ b/run/helloworld/package.json
@@ -19,6 +19,6 @@
"devDependencies": {
"got": "^11.0.0",
"mocha": "^8.0.0",
- "supertest": "^5.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/idp-sql/app.js b/run/idp-sql/app.js
index 0b5f9f4985..63ad7ab157 100644
--- a/run/idp-sql/app.js
+++ b/run/idp-sql/app.js
@@ -14,10 +14,10 @@
'use strict';
-const { getVotes, getVoteCount, insertVote } = require('./cloud-sql');
+const {getVotes, getVoteCount, insertVote} = require('./cloud-sql');
const express = require('express');
-const { buildRenderedHtml } = require('./handlebars');
-const { authenticateJWT, requestLogger } = require('./middleware');
+const {buildRenderedHtml} = require('./handlebars');
+const {authenticateJWT, requestLogger} = require('./middleware');
const app = express();
app.use(express.static(__dirname + '/static'));
@@ -54,7 +54,9 @@ app.get('/', requestLogger, async (req, res) => {
leadTeam = 'DOGS';
voteDiff = dogsTotalVotes - catsTotalVotes;
}
- leaderMessage = `${leadTeam} are winning by ${voteDiff} vote${voteDiff > 1 ? 's' : ''}.`;
+ leaderMessage = `${leadTeam} are winning by ${voteDiff} vote${
+ voteDiff > 1 ? 's' : ''
+ }.`;
} else {
leaderMessage = 'CATS and DOGS are evenly matched!';
}
@@ -70,9 +72,10 @@ app.get('/', requestLogger, async (req, res) => {
});
res.status(200).send(renderedHtml);
} catch (err) {
- const message = "Error while connecting to the Cloud SQL database. " +
- "Check that your username and password are correct, that the Cloud SQL " +
- "proxy is running (locally), and that the database/table exists and is " +
+ const message =
+ 'Error while connecting to the Cloud SQL database. ' +
+ 'Check that your username and password are correct, that the Cloud SQL ' +
+ 'proxy is running (locally), and that the database/table exists and is ' +
`ready for use: ${err}`;
req.logger.error(message); // request-based logger with trace support
res
@@ -104,7 +107,7 @@ app.post('/', requestLogger, authenticateJWT, async (req, res) => {
// Save the data to the database.
try {
await insertVote(vote);
- req.logger.info({message: 'vote_inserted', vote}); // request-based logger with trace support
+ req.logger.info({message: 'vote_inserted', vote}); // request-based logger with trace support
} catch (err) {
req.logger.error(`Error while attempting to submit vote: ${err}`);
res
diff --git a/run/idp-sql/cloud-sql.js b/run/idp-sql/cloud-sql.js
index 1ddcce46dd..2a89abd9a5 100644
--- a/run/idp-sql/cloud-sql.js
+++ b/run/idp-sql/cloud-sql.js
@@ -13,8 +13,8 @@
// limitations under the License.
const Knex = require('knex');
-const { getCredConfig } = require('./secrets');
-const { logger } = require('./logging');
+const {getCredConfig} = require('./secrets');
+const {logger} = require('./logging');
const TABLE = process.env.TABLE || 'votes';
let knex, credConfig;
@@ -31,17 +31,17 @@ const config = {
createTimeoutMillis: 30000,
idleTimeoutMillis: 600000,
createRetryIntervalMillis: 200,
-}
+};
// [START run_user_auth_sql_connect]
/**
-* Connect to the Cloud SQL instance through UNIX Sockets
-*
-* @param {object} credConfig The Cloud SQL connection configuration from Secret Manager
-* @returns {object} Knex's PostgreSQL client
-*/
-const connectWithUnixSockets = async (credConfig) => {
- const dbSocketPath = process.env.DB_SOCKET_PATH || "/cloudsql"
+ * Connect to the Cloud SQL instance through UNIX Sockets
+ *
+ * @param {object} credConfig The Cloud SQL connection configuration from Secret Manager
+ * @returns {object} Knex's PostgreSQL client
+ */
+const connectWithUnixSockets = async credConfig => {
+ const dbSocketPath = process.env.DB_SOCKET_PATH || '/cloudsql';
// Establish a connection to the database
return Knex({
client: 'pg',
@@ -51,15 +51,15 @@ const connectWithUnixSockets = async (credConfig) => {
database: credConfig.DB_NAME, // e.g. 'my-database'
host: `${dbSocketPath}/${credConfig.CLOUD_SQL_CONNECTION_NAME}`,
},
- ...config
+ ...config,
});
-}
+};
// [END run_user_auth_sql_connect]
// Method to connect locally on Windows
-const connectWithTcp = (credConfig) => {
+const connectWithTcp = credConfig => {
// Extract host and port from socket address
- const dbSocketAddr = process.env.DB_HOST.split(":") // e.g. '127.0.0.1:5432'
+ const dbSocketAddr = process.env.DB_HOST.split(':'); // e.g. '127.0.0.1:5432'
// Establish a connection to the database
return Knex({
client: 'pg',
@@ -70,17 +70,16 @@ const connectWithTcp = (credConfig) => {
host: dbSocketAddr[0], // e.g. '127.0.0.1'
port: dbSocketAddr[1], // e.g. '5432'
},
- ...config
+ ...config,
});
-}
-
+};
/**
-* Connect to the Cloud SQL instance through TCP or UNIX Sockets
-* dependent on DB_HOST env var
-*
-* @returns {object} Knex's PostgreSQL client
-*/
+ * Connect to the Cloud SQL instance through TCP or UNIX Sockets
+ * dependent on DB_HOST env var
+ *
+ * @returns {object} Knex's PostgreSQL client
+ */
const connect = async () => {
if (!credConfig) credConfig = await getCredConfig();
if (process.env.DB_HOST) {
@@ -88,24 +87,24 @@ const connect = async () => {
} else {
return connectWithUnixSockets(credConfig);
}
-}
+};
/**
-* Insert a vote record into the database.
-*
-* @param {object} vote The vote record to insert.
-* @returns {Promise}
-*/
-const insertVote = async (vote) => {
+ * Insert a vote record into the database.
+ *
+ * @param {object} vote The vote record to insert.
+ * @returns {Promise}
+ */
+const insertVote = async vote => {
if (!knex) knex = await connect();
return knex(TABLE).insert(vote);
};
/**
-* Retrieve the latest 5 vote records from the database.
-*
-* @returns {Promise}
-*/
+ * Retrieve the latest 5 vote records from the database.
+ *
+ * @returns {Promise}
+ */
const getVotes = async () => {
if (!knex) knex = await connect();
return knex
@@ -116,26 +115,26 @@ const getVotes = async () => {
};
/**
-* Retrieve the total count of records for a given candidate
-* from the database.
-*
-* @param {object} candidate The candidate for which to get the total vote count
-* @returns {Promise}
-*/
-const getVoteCount = async (candidate) => {
+ * Retrieve the total count of records for a given candidate
+ * from the database.
+ *
+ * @param {object} candidate The candidate for which to get the total vote count
+ * @returns {Promise}
+ */
+const getVoteCount = async candidate => {
if (!knex) knex = await connect();
return knex(TABLE).count('vote_id').where('candidate', candidate);
};
/**
-* Create "votes" table in the Cloud SQL database
-*/
+ * Create "votes" table in the Cloud SQL database
+ */
const createTable = async () => {
if (!knex) knex = await connect();
const exists = await knex.schema.hasTable(TABLE);
if (!exists) {
try {
- await knex.schema.createTable(TABLE, (table) => {
+ await knex.schema.createTable(TABLE, table => {
table.bigIncrements('vote_id').notNull();
table.timestamp('time_cast').notNull();
table.specificType('candidate', 'CHAR(6) NOT NULL');
@@ -152,7 +151,7 @@ const createTable = async () => {
const closeConnection = () => {
if (!knex) knex.destroy();
logger.info('DB connection closed.');
-}
+};
module.exports = {
getVoteCount,
@@ -160,4 +159,4 @@ module.exports = {
insertVote,
createTable,
closeConnection,
-}
+};
diff --git a/run/idp-sql/handlebars.js b/run/idp-sql/handlebars.js
index a8505469ca..4dbb969002 100644
--- a/run/idp-sql/handlebars.js
+++ b/run/idp-sql/handlebars.js
@@ -13,25 +13,25 @@
// limitations under the License.
const handlebars = require('handlebars');
-const { readFile } = require('fs').promises;
+const {readFile} = require('fs').promises;
let index, template;
/**
-* Builds and executes Handlebars.js template for rendered HTML
-*
-* @param {object} config The template config object.
-* @returns {Promise}
-*/
-const buildRenderedHtml = async (config) => {
+ * Builds and executes Handlebars.js template for rendered HTML
+ *
+ * @param {object} config The template config object.
+ * @returns {Promise}
+ */
+const buildRenderedHtml = async config => {
if (!index) index = await readFile(__dirname + '/views/index.html', 'utf8');
if (!template) template = handlebars.compile(index);
return template(config);
};
// Register customer Handlebars.js helper
-handlebars.registerHelper('ternary', function(comp1, comp2, opt1, opt2) {
- return (comp1.trim() == comp2.trim()) ? opt1 : opt2;
+handlebars.registerHelper('ternary', (comp1, comp2, opt1, opt2) => {
+ return comp1.trim() == comp2.trim() ? opt1 : opt2;
});
-module.exports = { buildRenderedHtml }
+module.exports = {buildRenderedHtml};
diff --git a/run/idp-sql/index.js b/run/idp-sql/index.js
index f4e68fdfcc..f630e917c3 100644
--- a/run/idp-sql/index.js
+++ b/run/idp-sql/index.js
@@ -14,11 +14,11 @@
const app = require('./app');
const pkg = require('./package.json');
-const { logger } = require('./logging');
-const { initTracing } = require('./middleware');
-const { createTable, closeConnection } = require('./cloud-sql');
+const {logger} = require('./logging');
+const {initTracing} = require('./middleware');
+const {createTable, closeConnection} = require('./cloud-sql');
-const { GoogleAuth } = require('google-auth-library');
+const {GoogleAuth} = require('google-auth-library');
const auth = new GoogleAuth();
const PORT = process.env.PORT || 8080;
@@ -49,7 +49,7 @@ process.on('SIGTERM', () => {
logger.on('finish', () => {
console.log(`${pkg.name}: logs flushed`);
process.exit(0);
- })
+ });
});
main();
diff --git a/run/idp-sql/logging.js b/run/idp-sql/logging.js
index 521b513758..583f1ace6b 100644
--- a/run/idp-sql/logging.js
+++ b/run/idp-sql/logging.js
@@ -13,7 +13,7 @@
// limitations under the License.
// Create a Winston logger that streams to Stackdriver Logging.
-const { createLogger, transports ,format } = require('winston');
+const {createLogger, transports, format} = require('winston');
// Add severity label for Stackdriver log parsing
const addSeverity = format((info, opts) => {
@@ -26,12 +26,12 @@ const logger = createLogger({
format: format.combine(
addSeverity(),
format.timestamp(),
- format.json(),
+ format.json()
// format.prettyPrint(), // Uncomment for local debugging
),
transports: [new transports.Console()],
});
module.exports = {
- logger
+ logger,
};
diff --git a/run/idp-sql/middleware.js b/run/idp-sql/middleware.js
index d290756767..0cf17e6ecc 100644
--- a/run/idp-sql/middleware.js
+++ b/run/idp-sql/middleware.js
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-const { logger } = require('./logging'); // Import winston logger instance
+const {logger} = require('./logging'); // Import winston logger instance
// [START run_user_auth_jwt]
const firebase = require('firebase-admin');
@@ -26,25 +26,28 @@ const authenticateJWT = (req, res, next) => {
const token = authHeader.split(' ')[1];
// If the provided ID token has the correct format, is not expired, and is
// properly signed, the method returns the decoded ID token
- firebase.auth().verifyIdToken(token).then(function(decodedToken) {
- let uid = decodedToken.uid;
- req.uid = uid;
- next();
- }).catch((err) => {
- req.logger.error(`Error with authentication: ${err}`);
- return res.sendStatus(403);
- });
+ firebase
+ .auth()
+ .verifyIdToken(token)
+ .then(decodedToken => {
+ const uid = decodedToken.uid;
+ req.uid = uid;
+ next();
+ })
+ .catch(err => {
+ req.logger.error(`Error with authentication: ${err}`);
+ return res.sendStatus(403);
+ });
} else {
return res.sendStatus(401);
}
-}
+};
// [END run_user_auth_jwt]
-
let project;
-const initTracing = (projectId) => {
+const initTracing = projectId => {
project = projectId;
-}
+};
// Add logging field with trace ID for logging correlation
// For more info, see https://cloud.google.com/run/docs/logging#correlate-logs
@@ -52,15 +55,15 @@ const requestLogger = (req, res, next) => {
const traceHeader = req.header('X-Cloud-Trace-Context');
let trace;
if (traceHeader) {
- const [traceId] = traceHeader.split("/");
+ const [traceId] = traceHeader.split('/');
trace = `projects/${project}/traces/${traceId}`;
}
req.logger = logger.child({'logging.googleapis.com/trace': trace});
next();
-}
+};
module.exports = {
authenticateJWT,
requestLogger,
- initTracing
-}
+ initTracing,
+};
diff --git a/run/idp-sql/package.json b/run/idp-sql/package.json
index 976f1ed634..6518311ac7 100644
--- a/run/idp-sql/package.json
+++ b/run/idp-sql/package.json
@@ -33,6 +33,6 @@
"mocha": "^8.0.0",
"short-uuid": "^4.1.0",
"sinon": "^9.2.0",
- "supertest": "^4.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/idp-sql/secrets.js b/run/idp-sql/secrets.js
index c67d67e997..c6c0a2b864 100644
--- a/run/idp-sql/secrets.js
+++ b/run/idp-sql/secrets.js
@@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-const { logger } = require('./logging');
+const {logger} = require('./logging');
// CLOUD_SQL_CREDENTIALS_SECRET is the resource ID of the secret, passed in by environment variable.
// Format: projects/PROJECT_ID/secrets/SECRET_ID/versions/VERSION
const {CLOUD_SQL_CREDENTIALS_SECRET} = process.env;
-
// [START run_user_auth_secrets]
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
let client;
@@ -43,24 +42,29 @@ async function getCredConfig() {
// to retreive database credentials
return JSON.parse(secrets.toString('utf8'));
} catch (err) {
- throw Error(`Unable to parse secret from Secret Manager. Make sure that the secret is JSON formatted: ${err}`)
+ throw Error(
+ `Unable to parse secret from Secret Manager. Make sure that the secret is JSON formatted: ${err}`
+ );
}
} else {
- logger.info('CLOUD_SQL_CREDENTIALS_SECRET env var not set. Defaulting to environment variables.');
+ logger.info(
+ 'CLOUD_SQL_CREDENTIALS_SECRET env var not set. Defaulting to environment variables.'
+ );
if (!process.env.DB_USER) throw Error('DB_USER needs to be set.');
if (!process.env.DB_PASSWORD) throw Error('DB_PASSWORD needs to be set.');
if (!process.env.DB_NAME) throw Error('DB_NAME needs to be set.');
- if (!process.env.CLOUD_SQL_CONNECTION_NAME) throw Error('CLOUD_SQL_CONNECTION_NAME needs to be set.');
+ if (!process.env.CLOUD_SQL_CONNECTION_NAME)
+ throw Error('CLOUD_SQL_CONNECTION_NAME needs to be set.');
return {
DB_USER: process.env.DB_USER,
DB_PASSWORD: process.env.DB_PASSWORD,
DB_NAME: process.env.DB_NAME,
- CLOUD_SQL_CONNECTION_NAME: process.env.CLOUD_SQL_CONNECTION_NAME
- }
+ CLOUD_SQL_CONNECTION_NAME: process.env.CLOUD_SQL_CONNECTION_NAME,
+ };
}
}
module.exports = {
- getCredConfig
-}
+ getCredConfig,
+};
diff --git a/run/idp-sql/static/config.js b/run/idp-sql/static/config.js
index 31f5a1822f..e9a35270fc 100644
--- a/run/idp-sql/static/config.js
+++ b/run/idp-sql/static/config.js
@@ -1,6 +1,6 @@
// [START run_end_user_firebase_config]
const config = {
- apiKey: "API_KEY",
- authDomain: "PROJECT_ID.firebaseapp.com",
+ apiKey: 'API_KEY',
+ authDomain: 'PROJECT_ID.firebaseapp.com',
};
// [END run_end_user_firebase_config]
diff --git a/run/idp-sql/static/firebase.js b/run/idp-sql/static/firebase.js
index 7e05f16cd5..b2f38b37f3 100644
--- a/run/idp-sql/static/firebase.js
+++ b/run/idp-sql/static/firebase.js
@@ -2,7 +2,7 @@ firebase.initializeApp(config);
// Watch for state change from sign in
function initApp() {
- firebase.auth().onAuthStateChanged(function(user) {
+ firebase.auth().onAuthStateChanged(user => {
if (user) {
// User is signed in.
document.getElementById('signInButton').innerText = 'Sign Out';
@@ -14,29 +14,36 @@ function initApp() {
}
});
}
-window.onload = function() {
+window.onload = function () {
initApp();
-}
+};
// [START run_end_user_firebase_sign_in]
function signIn() {
- var provider = new firebase.auth.GoogleAuthProvider();
+ const provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/userinfo.email');
- firebase.auth().signInWithPopup(provider).then(function(result) {
- // Returns the signed in user along with the provider's credential
- console.log(`${result.user.displayName} logged in.`);
- window.alert(`Welcome ${result.user.displayName}!`)
- }).catch((err) => {
- console.log(`Error during sign in: ${err.message}`)
- });
+ firebase
+ .auth()
+ .signInWithPopup(provider)
+ .then(result => {
+ // Returns the signed in user along with the provider's credential
+ console.log(`${result.user.displayName} logged in.`);
+ window.alert(`Welcome ${result.user.displayName}!`);
+ })
+ .catch(err => {
+ console.log(`Error during sign in: ${err.message}`);
+ });
}
// [END run_end_user_firebase_sign_in]
function signOut() {
- firebase.auth().signOut().then(function(result) {
- }).catch((err) => {
- console.log(`Error during sign out: ${err.message}`)
- })
+ firebase
+ .auth()
+ .signOut()
+ .then(result => {})
+ .catch(err => {
+ console.log(`Error during sign out: ${err.message}`);
+ });
}
// Toggle Sign in/out button
@@ -60,7 +67,7 @@ async function vote(team) {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': `Bearer ${token}`
+ Authorization: `Bearer ${token}`,
},
body: 'team=' + team, // send application data (vote)
});
diff --git a/run/idp-sql/test/app.test.js b/run/idp-sql/test/app.test.js
index 133d622804..d8323e2b37 100644
--- a/run/idp-sql/test/app.test.js
+++ b/run/idp-sql/test/app.test.js
@@ -17,7 +17,7 @@
const assert = require('assert');
const path = require('path');
const supertest = require('supertest');
-const { buildRenderedHtml } = require('../handlebars');
+const {buildRenderedHtml} = require('../handlebars');
let request;
@@ -28,9 +28,7 @@ describe('Unit Tests', () => {
});
it('should reject request without JWT token', async () => {
- await request
- .post('/')
- .expect(401);
+ await request.post('/').expect(401);
});
it('should reject request with invalid JWT token', async () => {
@@ -45,12 +43,11 @@ describe('Unit Tests', () => {
votes: [],
catsCount: 1,
dogsCount: 100,
- leadTeam: "Dogs",
+ leadTeam: 'Dogs',
voteDiff: 99,
- leaderMessage: "Dogs are winning",
+ leaderMessage: 'Dogs are winning',
});
assert(renderedHtml.includes('100 votes
'));
- })
-
+ });
});
diff --git a/run/idp-sql/test/system.test.js b/run/idp-sql/test/system.test.js
index 30d3554ff4..7f2efa33a7 100644
--- a/run/idp-sql/test/system.test.js
+++ b/run/idp-sql/test/system.test.js
@@ -17,7 +17,7 @@
const assert = require('assert');
const admin = require('firebase-admin');
const got = require('got');
-const { execSync } = require('child_process');
+const {execSync} = require('child_process');
admin.initializeApp();
@@ -30,7 +30,7 @@ describe('System Tests', () => {
let {SERVICE_NAME} = process.env;
if (!SERVICE_NAME) {
console.log('"SERVICE_NAME" env var not found. Defaulting to "idp-sql"');
- SERVICE_NAME = "idp-sql";
+ SERVICE_NAME = 'idp-sql';
}
const {SAMPLE_VERSION} = process.env;
const PLATFORM = 'managed';
@@ -56,13 +56,14 @@ describe('System Tests', () => {
let BASE_URL, ID_TOKEN;
before(async () => {
// Deploy service using Cloud Build
- const buildCmd = `gcloud builds submit --project ${GOOGLE_CLOUD_PROJECT} ` +
- `--config ./test/e2e_test_setup.yaml ` +
+ const buildCmd =
+ `gcloud builds submit --project ${GOOGLE_CLOUD_PROJECT} ` +
+ '--config ./test/e2e_test_setup.yaml ' +
`--substitutions _SERVICE=${SERVICE_NAME},_PLATFORM=${PLATFORM},_REGION=${REGION}` +
`,_DB_PASSWORD=${DB_PASSWORD},_CLOUD_SQL_CONNECTION_NAME=${CLOUD_SQL_CONNECTION_NAME}`;
- if(SAMPLE_VERSION) buildCmd + `,_VERSION=${SAMPLE_VERSION}`;
- if(DB_USER) buildCmd + `,_DB_USER=${DB_USER}`;
- if(DB_NAME) buildCmd + `,_DB_NAME=${DB_NAME}`;
+ if (SAMPLE_VERSION) buildCmd + `,_VERSION=${SAMPLE_VERSION}`;
+ if (DB_USER) buildCmd + `,_DB_USER=${DB_USER}`;
+ if (DB_NAME) buildCmd + `,_DB_NAME=${DB_NAME}`;
console.log('Starting Cloud Build...');
execSync(buildCmd);
@@ -71,37 +72,42 @@ describe('System Tests', () => {
// Retrieve URL of Cloud Run service
const url = execSync(
`gcloud run services describe ${SERVICE_NAME} --project=${GOOGLE_CLOUD_PROJECT} ` +
- `--platform=${PLATFORM} --region=${REGION} --format='value(status.url)'`);
+ `--platform=${PLATFORM} --region=${REGION} --format='value(status.url)'`
+ );
BASE_URL = url.toString('utf-8');
if (!BASE_URL) throw Error('Cloud Run service URL not found');
// Retrieve ID token for testing
const customToken = await admin.auth().createCustomToken('a-user-id');
- const response = await got(`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${IDP_KEY}`, {
- method: 'POST',
- body: JSON.stringify({
- token: customToken,
- returnSecureToken: true
- }),
- });
+ const response = await got(
+ `https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${IDP_KEY}`,
+ {
+ method: 'POST',
+ body: JSON.stringify({
+ token: customToken,
+ returnSecureToken: true,
+ }),
+ }
+ );
const tokens = JSON.parse(response.body);
ID_TOKEN = tokens.idToken;
if (!ID_TOKEN) throw Error('Unable to acquire an ID token.');
- })
+ });
after(() => {
- const cleanUpCmd = `gcloud builds submit --project ${GOOGLE_CLOUD_PROJECT} ` +
- `--config ./test/e2e_test_cleanup.yaml ` +
- `--substitutions _SERVICE=${SERVICE_NAME},_PLATFORM=${PLATFORM},_REGION=${REGION}`
- if(SAMPLE_VERSION) cleanUpCmd + `,_VERSION=${SAMPLE_VERSION}`;
+ const cleanUpCmd =
+ `gcloud builds submit --project ${GOOGLE_CLOUD_PROJECT} ` +
+ '--config ./test/e2e_test_cleanup.yaml ' +
+ `--substitutions _SERVICE=${SERVICE_NAME},_PLATFORM=${PLATFORM},_REGION=${REGION}`;
+ if (SAMPLE_VERSION) cleanUpCmd + `,_VERSION=${SAMPLE_VERSION}`;
execSync(cleanUpCmd);
- })
+ });
it('Can successfully make a request', async () => {
const options = {
prefixUrl: BASE_URL.trim(),
- retry: 3
+ retry: 3,
};
const response = await got('', options);
assert.strictEqual(response.statusCode, 200);
@@ -113,9 +119,9 @@ describe('System Tests', () => {
method: 'POST',
form: {team: 'DOGS'},
headers: {
- Authorization: `Bearer ${ID_TOKEN.trim()}`
+ Authorization: `Bearer ${ID_TOKEN.trim()}`,
},
- retry: 3
+ retry: 3,
};
const response = await got('', options);
assert.strictEqual(response.statusCode, 200);
@@ -127,9 +133,9 @@ describe('System Tests', () => {
method: 'POST',
form: {team: 'DOGS'},
headers: {
- Authorization: `Bearer iam-a-token`
+ Authorization: 'Bearer iam-a-token',
},
- retry: 3
+ retry: 3,
};
let err;
try {
@@ -145,7 +151,7 @@ describe('System Tests', () => {
prefixUrl: BASE_URL.trim(),
method: 'POST',
form: {team: 'DOGS'},
- retry: 3
+ retry: 3,
};
let err;
try {
@@ -155,5 +161,4 @@ describe('System Tests', () => {
}
assert.strictEqual(err.response.statusCode, 401);
});
-
});
diff --git a/run/image-processing/image.js b/run/image-processing/image.js
index 614147bc86..42f0cafb47 100644
--- a/run/image-processing/image.js
+++ b/run/image-processing/image.js
@@ -30,7 +30,7 @@ const {BLURRED_BUCKET_NAME} = process.env;
// [START run_imageproc_handler_analyze]
// Blurs uploaded images that are flagged as Adult or Violence.
-exports.blurOffensiveImages = async (event) => {
+exports.blurOffensiveImages = async event => {
// This event represents the triggering Cloud Storage object.
const object = event;
diff --git a/run/image-processing/package.json b/run/image-processing/package.json
index d7010e859f..7086b00884 100644
--- a/run/image-processing/package.json
+++ b/run/image-processing/package.json
@@ -28,6 +28,6 @@
"devDependencies": {
"got": "^11.5.0",
"mocha": "^8.0.0",
- "supertest": "^5.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/image-processing/test/app.test.js b/run/image-processing/test/app.test.js
index 89a4e14cde..d15fdd6208 100644
--- a/run/image-processing/test/app.test.js
+++ b/run/image-processing/test/app.test.js
@@ -10,11 +10,11 @@ describe('Unit Tests', () => {
});
describe('should fail', () => {
- it(`on a Bad Request with an empty payload`, async () => {
+ it('on a Bad Request with an empty payload', async () => {
await request.post('/').type('json').send('').expect(400);
});
- it(`on a Bad Request with an invalid payload`, async () => {
+ it('on a Bad Request with an invalid payload', async () => {
await request
.post('/')
.type('json')
@@ -22,11 +22,11 @@ describe('Unit Tests', () => {
.expect(400);
});
- it(`on a Bad Request with an invalid mimetype`, async () => {
+ it('on a Bad Request with an invalid mimetype', async () => {
await request.post('/').type('text').send('{message: true}').expect(400);
});
- it(`if the decoded message.data is not well-formed JSON`, async () => {
+ it('if the decoded message.data is not well-formed JSON', async () => {
await request
.post('/')
.type('json')
@@ -45,7 +45,7 @@ describe('Unit Tests', () => {
.type('json')
.send({
message: {
- data: Buffer.from('{ "json": "value" }').toString(`base64`),
+ data: Buffer.from('{ "json": "value" }').toString('base64'),
},
})
.expect(400);
@@ -56,7 +56,7 @@ describe('Unit Tests', () => {
.type('json')
.send({
message: {
- data: Buffer.from('{ "name": "value" }').toString(`base64`),
+ data: Buffer.from('{ "name": "value" }').toString('base64'),
},
})
.expect(400);
@@ -67,7 +67,7 @@ describe('Unit Tests', () => {
.type('json')
.send({
message: {
- data: Buffer.from('{ "bucket": "value" }').toString(`base64`),
+ data: Buffer.from('{ "bucket": "value" }').toString('base64'),
},
})
.expect(400);
@@ -77,15 +77,15 @@ describe('Unit Tests', () => {
});
describe('Integration Tests', () => {
- it(`Image analysis can proceed to Vision API scan`, async () => {
+ it('Image analysis can proceed to Vision API scan', async () => {
await request
.post('/')
.type('json')
.send({
message: {
data: Buffer.from(
- `{ "bucket": "---", "name": "does-not-exist" }`
- ).toString(`base64`),
+ '{ "bucket": "---", "name": "does-not-exist" }'
+ ).toString('base64'),
},
})
.expect(204);
diff --git a/run/logging-manual/test/system.test.js b/run/logging-manual/test/system.test.js
index 0e055e6259..de93c86fec 100644
--- a/run/logging-manual/test/system.test.js
+++ b/run/logging-manual/test/system.test.js
@@ -33,7 +33,7 @@ const getLogEntriesPolling = async (filter, max_attempts) => {
return [];
};
-const getLogEntries = async (filter) => {
+const getLogEntries = async filter => {
const preparedFilter = `resource.type="cloud_run_revision" ${filter}`;
const entries = await logging.getEntries({
filter: preparedFilter,
@@ -83,7 +83,7 @@ describe('Logging', () => {
5
)}"`;
const entries = await getLogEntriesPolling(filter);
- entries.forEach((entry) => {
+ entries.forEach(entry => {
if (entry.metadata.httpRequest) {
requestLog = entry;
} else {
diff --git a/run/markdown-preview/editor/app.js b/run/markdown-preview/editor/app.js
index ab17d3e6f0..ee5375ab50 100644
--- a/run/markdown-preview/editor/app.js
+++ b/run/markdown-preview/editor/app.js
@@ -14,7 +14,7 @@
const express = require('express');
const handlebars = require('handlebars');
-const { readFile } = require('fs').promises;
+const {readFile} = require('fs').promises;
const renderRequest = require('./render.js');
const app = express();
@@ -26,15 +26,17 @@ let markdownDefault, compiledTemplate, renderedHtml;
const buildRenderedHtml = async () => {
try {
markdownDefault = await readFile(__dirname + '/templates/markdown.md');
- compiledTemplate = handlebars.compile(await readFile(__dirname + '/templates/index.html', 'utf8'));
+ compiledTemplate = handlebars.compile(
+ await readFile(__dirname + '/templates/index.html', 'utf8')
+ );
renderedHtml = compiledTemplate({default: markdownDefault});
return renderedHtml;
- } catch(err) {
- throw Error ('Error loading template: ', err);
+ } catch (err) {
+ throw Error('Error loading template: ', err);
}
};
-app.get('/', async (req, res) => {
+app.get('/', async (req, res) => {
try {
if (!renderedHtml) renderedHtml = await buildRenderedHtml();
res.status(200).send(renderedHtml);
@@ -44,7 +46,7 @@ app.get('/', async (req, res) => {
}
});
-// The renderRequest makes a request to the Renderer service.
+// The renderRequest makes a request to the Renderer service.
// The request returns the Markdown text converted to HTML.
// [START run_secure_request_do]
app.post('/render', async (req, res) => {
@@ -62,5 +64,5 @@ app.post('/render', async (req, res) => {
// Exports for testing purposes.
module.exports = {
app,
- buildRenderedHtml
-};
\ No newline at end of file
+ buildRenderedHtml,
+};
diff --git a/run/markdown-preview/editor/index.js b/run/markdown-preview/editor/index.js
index 3e56daf1aa..73512995b6 100644
--- a/run/markdown-preview/editor/index.js
+++ b/run/markdown-preview/editor/index.js
@@ -16,6 +16,4 @@ const {app} = require('./app');
const pkg = require('./package.json');
const PORT = process.env.PORT || 8080;
-app.listen(PORT, () =>
- console.log(`${pkg.name} listening on port ${PORT}`)
-);
+app.listen(PORT, () => console.log(`${pkg.name} listening on port ${PORT}`));
diff --git a/run/markdown-preview/editor/package.json b/run/markdown-preview/editor/package.json
index 458afb28f8..86b59282c0 100644
--- a/run/markdown-preview/editor/package.json
+++ b/run/markdown-preview/editor/package.json
@@ -26,6 +26,6 @@
},
"devDependencies": {
"mocha": "^8.0.0",
- "supertest": "^5.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/markdown-preview/editor/render.js b/run/markdown-preview/editor/render.js
index b68102c211..7fe4720378 100644
--- a/run/markdown-preview/editor/render.js
+++ b/run/markdown-preview/editor/render.js
@@ -22,18 +22,19 @@ let client, serviceUrl;
// renderRequest creates a new HTTP request with IAM ID Token credential.
// This token is automatically handled by private Cloud Run (fully managed) and Cloud Functions.
-const renderRequest = async (markdown) => {
- if (!process.env.EDITOR_UPSTREAM_RENDER_URL) throw Error('EDITOR_UPSTREAM_RENDER_URL needs to be set.');
+const renderRequest = async markdown => {
+ if (!process.env.EDITOR_UPSTREAM_RENDER_URL)
+ throw Error('EDITOR_UPSTREAM_RENDER_URL needs to be set.');
serviceUrl = process.env.EDITOR_UPSTREAM_RENDER_URL;
// Build the request to the Renderer receiving service.
- const serviceRequestOptions = {
+ const serviceRequestOptions = {
method: 'POST',
headers: {
- 'Content-Type': 'text/plain'
+ 'Content-Type': 'text/plain',
},
body: markdown,
- timeout: 3000
+ timeout: 3000,
};
try {
@@ -42,18 +43,19 @@ const renderRequest = async (markdown) => {
// Fetch the client request headers and add them to the service request headers.
// The client request headers include an ID token that authenticates the request.
const clientHeaders = await client.getRequestHeaders();
- serviceRequestOptions.headers['Authorization'] = clientHeaders['Authorization'];
- } catch(err) {
+ serviceRequestOptions.headers['Authorization'] =
+ clientHeaders['Authorization'];
+ } catch (err) {
throw Error('could not create an identity token: ', err);
- };
+ }
try {
// serviceResponse converts the Markdown plaintext to HTML.
const serviceResponse = await got(serviceUrl, serviceRequestOptions);
return serviceResponse.body;
- } catch (err) {
+ } catch (err) {
throw Error('request to rendering service failed: ', err);
- };
+ }
};
// [END run_secure_request]
diff --git a/run/markdown-preview/editor/test/app.test.js b/run/markdown-preview/editor/test/app.test.js
index 643d2e05d8..8a74c50856 100644
--- a/run/markdown-preview/editor/test/app.test.js
+++ b/run/markdown-preview/editor/test/app.test.js
@@ -20,27 +20,26 @@ const supertest = require('supertest');
describe('Editor unit tests', () => {
describe('Initialize app', () => {
- it('should successfully load the index page', async function () {
+ it('should successfully load the index page', async () => {
const {app} = require(path.join(__dirname, '..', 'app'));
const request = supertest(app);
await request.get('/').expect(200);
- })
+ });
});
describe('Handlebars compiler', async () => {
let template;
- before( async () => {
+ before(async () => {
const {buildRenderedHtml} = require(path.join(__dirname, '..', 'app'));
template = await buildRenderedHtml();
- })
+ });
it('includes HTML from the templates', () => {
- let htmlString = template.includes('Markdown Editor');
+ const htmlString = template.includes('Markdown Editor');
assert.equal(htmlString, true);
});
});
-
});
describe('Integration tests', () => {
@@ -60,12 +59,22 @@ describe('Integration tests', () => {
it('responds 200 OK on "POST /render" with valid JSON', async () => {
// A valid type will make a request to the /render endpoint.
// TODO: This test outputs a JSON parsing SyntaxError from supertest but does not fail the assert.
- await request.post('/render').type('json').set('Accept', 'text/html').send({"data":"markdown"}).expect(200).expect('content-type', 'text/html; charset=utf-8');
+ await request
+ .post('/render')
+ .type('json')
+ .set('Accept', 'text/html')
+ .send({data: 'markdown'})
+ .expect(200)
+ .expect('content-type', 'text/html; charset=utf-8');
});
-
+
it('responds 400 Bad Request on "POST /render" without valid JSON', async () => {
- // An incorrect type will not successfully make a request and will print an error in the console.
- await request.post('/render').type('json').send('string: incorrect data type').expect(400);
+ // An incorrect type will not successfully make a request and will print an error in the console.
+ await request
+ .post('/render')
+ .type('json')
+ .send('string: incorrect data type')
+ .expect(400);
});
});
});
diff --git a/run/markdown-preview/editor/test/system.test.js b/run/markdown-preview/editor/test/system.test.js
index 23fa1c3d0b..7edb4926c6 100644
--- a/run/markdown-preview/editor/test/system.test.js
+++ b/run/markdown-preview/editor/test/system.test.js
@@ -27,15 +27,15 @@ describe('End-to-End Tests', () => {
throw Error(
'"BASE_URL" environment variable is required. For example: https://service-x8xabcdefg-uc.a.run.app'
);
- };
+ }
it('Can successfully make a request', async () => {
const options = {
prefixUrl: BASE_URL.trim(),
headers: {
- Authorization: `Bearer ${ID_TOKEN.trim()}`
+ Authorization: `Bearer ${ID_TOKEN.trim()}`,
},
- retry: 3
+ retry: 3,
};
const response = await got('', options);
assert.strictEqual(response.statusCode, 200);
@@ -46,18 +46,17 @@ describe('End-to-End Tests', () => {
prefixUrl: BASE_URL.trim(),
headers: {
Authorization: `Bearer ${ID_TOKEN.trim()}`,
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json',
},
method: 'POST',
- json: {
- "data": "**markdown**"
+ json: {
+ data: '**markdown**',
},
- retry: 3
+ retry: 3,
};
const response = await got('render', options);
assert.strictEqual(response.statusCode, 200);
assert.strictEqual(response.body, 'markdown
\n');
});
});
-
});
diff --git a/run/markdown-preview/renderer/app.js b/run/markdown-preview/renderer/app.js
index 2c1e6c8f26..a984b37045 100644
--- a/run/markdown-preview/renderer/app.js
+++ b/run/markdown-preview/renderer/app.js
@@ -19,12 +19,12 @@ const app = express();
app.use(express.text());
app.post('/', (req, res) => {
- if (typeof(req.body) !== 'string') {
+ if (typeof req.body !== 'string') {
const msg = 'Markdown data could not be retrieved.';
console.log(msg);
res.status(400).send(`Error: ${msg}`);
return;
- };
+ }
const markdown = req.body;
try {
// Get the Markdown text and convert it into HTML using markdown-it.
@@ -33,11 +33,11 @@ app.post('/', (req, res) => {
const md = new MarkdownIt();
const html = md.render(markdown);
res.status(200).send(html);
- } catch(err) {
+ } catch (err) {
console.log('Error rendering Markdown: ', err);
res.status(400).send(err);
}
-})
+});
// Export for testing purposes.
module.exports = app;
diff --git a/run/markdown-preview/renderer/index.js b/run/markdown-preview/renderer/index.js
index 90bcfa3924..a04863db38 100644
--- a/run/markdown-preview/renderer/index.js
+++ b/run/markdown-preview/renderer/index.js
@@ -16,6 +16,4 @@ const app = require('./app');
const pkg = require('./package.json');
const PORT = process.env.PORT || 8080;
-app.listen(PORT, () =>
- console.log(`${pkg.name} listening on port ${PORT}`)
-);
\ No newline at end of file
+app.listen(PORT, () => console.log(`${pkg.name} listening on port ${PORT}`));
diff --git a/run/markdown-preview/renderer/package.json b/run/markdown-preview/renderer/package.json
index a801cc42d7..202e8d5ff0 100644
--- a/run/markdown-preview/renderer/package.json
+++ b/run/markdown-preview/renderer/package.json
@@ -25,6 +25,6 @@
"got": "^11.5.0",
"mocha": "^8.0.0",
"sinon": "^9.0.2",
- "supertest": "^5.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/markdown-preview/renderer/test/app.test.js b/run/markdown-preview/renderer/test/app.test.js
index ee40373f41..f41033bef1 100644
--- a/run/markdown-preview/renderer/test/app.test.js
+++ b/run/markdown-preview/renderer/test/app.test.js
@@ -30,30 +30,50 @@ describe('Unit Tests', () => {
it('should return Bad Request with an invalid type', async () => {
const consoleStub = sinon.stub(console, 'log');
// Ensure that the expected error is logged.
- await request.post('/').type('json').send({"json": "json"});
+ await request.post('/').type('json').send({json: 'json'});
const message = console.log.getCall(0).args[0];
- assert.equal(message, "Markdown data could not be retrieved.");
+ assert.equal(message, 'Markdown data could not be retrieved.');
consoleStub.restore();
});
it('should succeed with a valid request', async () => {
- const markdown = "**markdown text**";
- const response = await request.post('/').type('text').send(markdown).expect(200);
+ const markdown = '**markdown text**';
+ const response = await request
+ .post('/')
+ .type('text')
+ .send(markdown)
+ .expect(200);
const body = response.text;
- assert.equal(body, "markdown text
\n")
+ assert.equal(body, 'markdown text
\n');
});
it('should succeed with a request that includes xss', async () => {
- let markdown = "";
- await request.post('/').type('text').send(markdown).expect(200).then(res => {
- const body = res.text;
- assert.deepStrictEqual(body, "<script>script</script>
\n");
- });
- markdown = 'Google'
- await request.post('/').type('text').send(markdown).expect(200).then(res => {
- const body = res.text;
- assert.deepStrictEqual(body, "<a onblur="alert(secret)" href="http://www.google.com">Google</a>
\n");
- });
- })
-})
-
+ let markdown = '';
+ await request
+ .post('/')
+ .type('text')
+ .send(markdown)
+ .expect(200)
+ .then(res => {
+ const body = res.text;
+ assert.deepStrictEqual(
+ body,
+ '<script>script</script>
\n'
+ );
+ });
+ markdown =
+ 'Google';
+ await request
+ .post('/')
+ .type('text')
+ .send(markdown)
+ .expect(200)
+ .then(res => {
+ const body = res.text;
+ assert.deepStrictEqual(
+ body,
+ '<a onblur="alert(secret)" href="http://www.google.com">Google</a>
\n'
+ );
+ });
+ });
+});
diff --git a/run/pubsub/app.js b/run/pubsub/app.js
index 2cb52082bf..d8dfee00c0 100644
--- a/run/pubsub/app.js
+++ b/run/pubsub/app.js
@@ -36,5 +36,3 @@ app.post('/', (req, res) => {
module.exports = app;
// [END run_pubsub_handler]
-
-
diff --git a/run/pubsub/package.json b/run/pubsub/package.json
index 5590e574d9..0ce7daf25c 100644
--- a/run/pubsub/package.json
+++ b/run/pubsub/package.json
@@ -26,7 +26,7 @@
"got": "^11.5.0",
"mocha": "^8.0.0",
"sinon": "^9.0.0",
- "supertest": "^5.0.0",
+ "supertest": "^6.0.0",
"uuid": "^8.0.0"
}
}
diff --git a/run/pubsub/test/app.test.js b/run/pubsub/test/app.test.js
index 7d11777053..ca7c9a4319 100644
--- a/run/pubsub/test/app.test.js
+++ b/run/pubsub/test/app.test.js
@@ -33,11 +33,11 @@ describe('Unit Tests', () => {
});
describe('should fail', () => {
- it(`on a Bad Request with an empty payload`, async () => {
+ it('on a Bad Request with an empty payload', async () => {
await request.post('/').type('json').send('').expect(400);
});
- it(`on a Bad Request with an invalid payload`, async () => {
+ it('on a Bad Request with an invalid payload', async () => {
await request
.post('/')
.type('json')
@@ -45,7 +45,7 @@ describe('Unit Tests', () => {
.expect(400);
});
- it(`on a Bad Request with an invalid mimetype`, async () => {
+ it('on a Bad Request with an invalid mimetype', async () => {
await request.post('/').type('text').send('{message: true}').expect(400);
});
});
@@ -60,7 +60,7 @@ describe('Unit Tests', () => {
console.log.restore();
});
- it(`with a minimally valid Pub/Sub Message`, async () => {
+ it('with a minimally valid Pub/Sub Message', async () => {
await request
.post('/')
.type('json')
@@ -69,9 +69,9 @@ describe('Unit Tests', () => {
.expect(() => assert.ok(console.log.calledWith('Hello World!')));
});
- it(`with a populated Pub/Sub Message`, async () => {
+ it('with a populated Pub/Sub Message', async () => {
const name = uuid.v4();
- const data = Buffer.from(name).toString(`base64`);
+ const data = Buffer.from(name).toString('base64');
await request
.post('/')
diff --git a/run/system-package/app.js b/run/system-package/app.js
index eb91d42236..4b0c6eed6c 100644
--- a/run/system-package/app.js
+++ b/run/system-package/app.js
@@ -44,7 +44,7 @@ app.get('/diagram.png', (req, res) => {
// [START run_system_package_exec]
// Generate a diagram based on a graphviz DOT diagram description.
-const createDiagram = (dot) => {
+const createDiagram = dot => {
if (!dot) {
throw new Error('syntax: no graphviz definition provided');
}
diff --git a/run/system-package/package.json b/run/system-package/package.json
index 5fa72feb72..a4011fe51e 100644
--- a/run/system-package/package.json
+++ b/run/system-package/package.json
@@ -15,6 +15,6 @@
"devDependencies": {
"got": "^11.5.0",
"mocha": "^8.0.0",
- "supertest": "^5.0.0"
+ "supertest": "^6.0.0"
}
}
diff --git a/run/system-package/test/app.test.js b/run/system-package/test/app.test.js
index fa82ccb021..566860e608 100644
--- a/run/system-package/test/app.test.js
+++ b/run/system-package/test/app.test.js
@@ -24,41 +24,41 @@ describe('Unit Tests', () => {
describe('should fail', () => {
const errorContentType = 'text/html; charset=utf-8';
- it(`should fail on a Bad Request with an empty query string`, async () => {
+ it('should fail on a Bad Request with an empty query string', async () => {
await request
.get('/diagram.png')
.type('text')
.expect(400)
.expect('Content-Type', errorContentType)
- .expect((res) => {
+ .expect(res => {
if (res.headers['cache-control']) {
throw new Error('Found cache header on uncached response');
}
});
});
- it(`should fail on a Bad Request with an empty dot parameter`, async () => {
+ it('should fail on a Bad Request with an empty dot parameter', async () => {
await request
.get('/diagram.png')
.type('text')
.query({dot: ''})
.expect(400)
.expect('Content-Type', errorContentType)
- .expect((res) => {
+ .expect(res => {
if (res.headers['cache-control']) {
throw new Error('Found cache header on uncached response');
}
});
});
- it(`should fail on a Bad Request with an invalid payload`, async () => {
+ it('should fail on a Bad Request with an invalid payload', async () => {
await request
- .get(`/diagram.png`)
+ .get('/diagram.png')
.type('text')
- .query({dot: `digraph`})
+ .query({dot: 'digraph'})
.expect(400)
.expect('Content-Type', errorContentType)
- .expect((res) => {
+ .expect(res => {
if (res.headers['cache-control']) {
throw new Error('Found cache header on uncached response');
}
@@ -67,11 +67,11 @@ describe('Unit Tests', () => {
});
describe('should succeed', () => {
- it(`should succeed with a valid DOT description`, async () => {
+ it('should succeed with a valid DOT description', async () => {
await request
- .get(`/diagram.png`)
- .type(`text`)
- .query({dot: `digraph G { A -> {B, C, D} -> {F} }`})
+ .get('/diagram.png')
+ .type('text')
+ .query({dot: 'digraph G { A -> {B, C, D} -> {F} }'})
.expect(200)
.expect('Content-Type', 'image/png')
.expect('Cache-Control', 'public, max-age=86400');
diff --git a/storage-transfer/package.json b/storage-transfer/package.json
index 0a4767d7e8..1c5bf85171 100644
--- a/storage-transfer/package.json
+++ b/storage-transfer/package.json
@@ -17,7 +17,7 @@
"test": "npm run unit-test && npm run system-test"
},
"dependencies": {
- "googleapis": "^61.0.0",
+ "googleapis": "^62.0.0",
"moment": "^2.24.0",
"yargs": "^16.0.0"
},
diff --git a/storage-transfer/system-test/transfer.test.js b/storage-transfer/system-test/transfer.test.js
index 21634d8a84..ee8ef3a0bd 100644
--- a/storage-transfer/system-test/transfer.test.js
+++ b/storage-transfer/system-test/transfer.test.js
@@ -33,8 +33,8 @@ const description = 'this is a test';
const status = 'DISABLED';
const stubConsole = function stubConsole() {
- sinon.stub(console, `error`);
- sinon.stub(console, `log`);
+ sinon.stub(console, 'error');
+ sinon.stub(console, 'log');
};
const restoreConsole = function restoreConsole() {
@@ -45,11 +45,11 @@ const restoreConsole = function restoreConsole() {
before(async () => {
assert(
process.env.GOOGLE_CLOUD_PROJECT,
- `Must set GOOGLE_CLOUD_PROJECT environment variable!`
+ 'Must set GOOGLE_CLOUD_PROJECT environment variable!'
);
assert(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
- `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!`
+ 'Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!'
);
stubConsole();
@@ -89,7 +89,7 @@ after(() => {
} catch (err) {} // ignore error
});
-it('should create a storage transfer job', (done) => {
+it('should create a storage transfer job', done => {
const options = {
srcBucket: firstBucketName,
destBucket: secondBucketName,
@@ -113,7 +113,7 @@ it('should create a storage transfer job', (done) => {
});
});
-it('should get a transferJob', (done) => {
+it('should get a transferJob', done => {
program.getTransferJob(jobName, (err, transferJob) => {
assert.ifError(err);
assert.strictEqual(transferJob.name, jobName);
@@ -127,7 +127,7 @@ it('should get a transferJob', (done) => {
});
});
-it('should update a transferJob', (done) => {
+it('should update a transferJob', done => {
const options = {
job: jobName,
field: 'status',
@@ -147,21 +147,19 @@ it('should update a transferJob', (done) => {
});
});
-it('should list transferJobs', (done) => {
+it('should list transferJobs', done => {
program.listTransferJobs((err, transferJobs) => {
assert.ifError(err);
assert.strictEqual(
- transferJobs.some((transferJob) => transferJob.name === jobName),
+ transferJobs.some(transferJob => transferJob.name === jobName),
true
);
assert.strictEqual(
- transferJobs.some(
- (transferJob) => transferJob.description === description
- ),
+ transferJobs.some(transferJob => transferJob.description === description),
true
);
assert.strictEqual(
- transferJobs.some((transferJob) => transferJob.status === status),
+ transferJobs.some(transferJob => transferJob.status === status),
true
);
assert.strictEqual(
@@ -172,7 +170,7 @@ it('should list transferJobs', (done) => {
});
});
-it('should list transferOperations', (done) => {
+it('should list transferOperations', done => {
program.listTransferOperations(jobName, (err, operations) => {
assert.ifError(err);
assert.strictEqual(Array.isArray(operations), true);
diff --git a/storage-transfer/test/transfer.test.js b/storage-transfer/test/transfer.test.js
index 3cee6a918b..31b406a682 100644
--- a/storage-transfer/test/transfer.test.js
+++ b/storage-transfer/test/transfer.test.js
@@ -75,8 +75,8 @@ const getSample = () => {
};
};
const stubConsole = function () {
- sinon.stub(console, `error`);
- sinon.stub(console, `log`);
+ sinon.stub(console, 'error');
+ sinon.stub(console, 'log');
};
//Restore console
diff --git a/storage-transfer/transfer.js b/storage-transfer/transfer.js
index d8c97f0b41..92ffe10d69 100644
--- a/storage-transfer/transfer.js
+++ b/storage-transfer/transfer.js
@@ -24,9 +24,9 @@ const storagetransfer = google.storagetransfer('v1');
// [END setup]
// [START auth]
-const auth = async (callback) => {
+const auth = async callback => {
const authClient = await google.auth.getClient({
- scopes: ['https://www.googleapis.com/auth/cloud-platform']
+ scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
callback(authClient);
@@ -49,7 +49,7 @@ const createTransferJob = (options, callback) => {
const startDate = moment(options.date, 'YYYY/MM/DD');
const transferTime = moment(options.time, 'HH:mm');
- auth((authClient) => {
+ auth(authClient => {
const transferJob = {
projectId: process.env.GOOGLE_CLOUD_PROJECT,
status: 'ENABLED',
@@ -107,7 +107,7 @@ const createTransferJob = (options, callback) => {
* @param {function} callback The callback function.
*/
const getTransferJob = (jobName, callback) => {
- auth((authClient) => {
+ auth(authClient => {
storagetransfer.transferJobs.get(
{
auth: authClient,
@@ -139,7 +139,7 @@ const getTransferJob = (jobName, callback) => {
* @param {function} callback The callback function.
*/
const updateTransferJob = (options, callback) => {
- auth((authClient) => {
+ auth(authClient => {
const patchRequest = {
projectId: process.env.GOOGLE_CLOUD_PROJECT,
transferJob: {
@@ -182,8 +182,8 @@ const updateTransferJob = (options, callback) => {
*
* @param {function} callback The callback function.
*/
-const listTransferJobs = (callback) => {
- auth((authClient) => {
+const listTransferJobs = callback => {
+ auth(authClient => {
storagetransfer.transferJobs.list(
{
auth: authClient,
@@ -212,7 +212,7 @@ const listTransferJobs = (callback) => {
* @param {function} callback The callback function.
*/
const listTransferOperations = (jobName, callback) => {
- auth((authClient) => {
+ auth(authClient => {
const filter = {
project_id: process.env.GOOGLE_CLOUD_PROJECT,
};
@@ -250,7 +250,7 @@ const listTransferOperations = (jobName, callback) => {
* @param {function} callback The callback function.
*/
const getTransferOperation = (transferOperationName, callback) => {
- auth((authClient) => {
+ auth(authClient => {
storagetransfer.transferOperations.get(
{
name: transferOperationName,
@@ -278,13 +278,13 @@ const getTransferOperation = (transferOperationName, callback) => {
* @param {function} callback The callback function.
*/
const pauseTransferOperation = (transferOperationName, callback) => {
- auth((authClient) => {
+ auth(authClient => {
storagetransfer.transferOperations.pause(
{
name: transferOperationName,
auth: authClient,
},
- (err) => {
+ err => {
if (err) {
return callback(err);
}
@@ -305,13 +305,13 @@ const pauseTransferOperation = (transferOperationName, callback) => {
* @param {function} callback The callback function.
*/
const resumeTransferOperation = (transferOperationName, callback) => {
- auth((authClient) => {
+ auth(authClient => {
storagetransfer.transferOperations.resume(
{
name: transferOperationName,
auth: authClient,
},
- (err) => {
+ err => {
if (err) {
return callback(err);
}
@@ -337,7 +337,7 @@ const program = (module.exports = {
getTransferOperation: getTransferOperation,
pauseTransferOperation: pauseTransferOperation,
resumeTransferOperation: resumeTransferOperation,
- main: (args) => {
+ main: args => {
// Run the command-line program
cli.help().strict().parse(args).argv; // eslint-disable-line
},
@@ -348,14 +348,14 @@ cli
.command(
'jobs [args]',
'Run a job command.',
- (yargs) => {
+ yargs => {
yargs
.demand(2)
.command(
'create