From cb31585cdf3297994d97064ea1123ce494620cc1 Mon Sep 17 00:00:00 2001 From: Grant Timmerman Date: Mon, 23 Sep 2019 09:49:07 -0300 Subject: [PATCH] refactor: prefer template strings --- cloud-sql/mysql/mysql/server.js | 2 +- cloud-sql/postgres/knex/server.js | 2 +- functions/billing/index.js | 2 +- functions/scheduleinstance/index.js | 4 ++-- functions/tokenservice/functions/index.js | 5 ++--- iot/http_example/cloudiot_http_example.js | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cloud-sql/mysql/mysql/server.js b/cloud-sql/mysql/mysql/server.js index 4681af584b..774a0f5976 100644 --- a/cloud-sql/mysql/mysql/server.js +++ b/cloud-sql/mysql/mysql/server.js @@ -156,7 +156,7 @@ app.post('/', async (req, res) => { res .status(200) - .send('Successfully voted for ' + team + ' at ' + timestamp) + .send(`Successfully voted for ${team} at ${timestamp}`) .end(); }); diff --git a/cloud-sql/postgres/knex/server.js b/cloud-sql/postgres/knex/server.js index c58d08e48c..e99361e110 100644 --- a/cloud-sql/postgres/knex/server.js +++ b/cloud-sql/postgres/knex/server.js @@ -212,7 +212,7 @@ app.post('/', async (req, res) => { try { await insertVote(knex, vote); } catch (err) { - logger.error('Error while attempting to submit vote:' + err); + logger.error(`Error while attempting to submit vote:${err}`); res .status(500) .send('Unable to cast vote; see logs for more details.') diff --git a/functions/billing/index.js b/functions/billing/index.js index 9be57c4ae3..4cdc28ecc8 100644 --- a/functions/billing/index.js +++ b/functions/billing/index.js @@ -187,7 +187,7 @@ const _stopInstances = async (projectId, zone, instanceNames) => { instance: instanceName, }) .then(res => { - console.log('Instance stopped successfully: ' + instanceName); + console.log(`Instance stopped successfully: ${instanceName}`); return res.data; }); }) diff --git a/functions/scheduleinstance/index.js b/functions/scheduleinstance/index.js index f30e567f00..03e8470b2e 100644 --- a/functions/scheduleinstance/index.js +++ b/functions/scheduleinstance/index.js @@ -51,7 +51,7 @@ exports.startInstancePubSub = (event, context, callback) => { }) .then(() => { // Operation complete. Instance successfully started. - const message = 'Successfully started instance ' + instance.name; + const message = `Successfully started instance ${instance.name}`; console.log(message); callback(null, message); }) @@ -101,7 +101,7 @@ exports.stopInstancePubSub = (event, context, callback) => { }) .then(() => { // Operation complete. Instance successfully stopped. - const message = 'Successfully stopped instance ' + instance.name; + const message = `Successfully stopped instance ${instance.name}`; console.log(message); callback(null, message); }) diff --git a/functions/tokenservice/functions/index.js b/functions/tokenservice/functions/index.js index cd9feff53f..a5f8f1fcb9 100644 --- a/functions/tokenservice/functions/index.js +++ b/functions/tokenservice/functions/index.js @@ -49,8 +49,7 @@ function generateAccessToken( method: 'POST', headers: { // Set Service Account Credentials - Authorization: - serviceAccountTokenType + ' ' + serviceAccountAccessToken, + Authorization: `${serviceAccountTokenType} ${serviceAccountAccessToken}`, }, }; @@ -120,7 +119,7 @@ function retrieveCredentials(context) { }); get_req.on('error', e => { //console.log('Error retrieving credentials', e.message); - return 'Error retrieving token' + e.message; + return `Error retrieving token: ${e.message}`; }); get_req.end(); }); diff --git a/iot/http_example/cloudiot_http_example.js b/iot/http_example/cloudiot_http_example.js index de2d4103f2..0dbba3d2ba 100644 --- a/iot/http_example/cloudiot_http_example.js +++ b/iot/http_example/cloudiot_http_example.js @@ -174,7 +174,7 @@ function publishAsync(authToken, messageCount, numMessages) { if (error) { console.error('Received error: ', error); } else if (response.body.error) { - console.error('Received error: ' + JSON.stringify(response.body.error)); + console.error(`Received error: ${JSON.stringify(response.body.error)}`); } else { console.log('Message sent.'); } @@ -205,7 +205,7 @@ function getConfig(authToken, version) { console.log(`Getting config from URL: ${urlBase}`); const options = { - url: urlBase + '/config?local_version=' + version, + url: `${urlBase}/config?local_version=${version}`, headers: { authorization: `Bearer ${authToken}`, 'content-type': 'application/json',