diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 6fa7e084d8..eda1fed587 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -12,7 +12,7 @@ build_file: "nodejs-docs-samples/.kokoro/trampoline.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" } # Export XUnit test results for further analysis diff --git a/appengine/analytics/app.js b/appengine/analytics/app.js index 47ee3276c6..057318eb37 100644 --- a/appengine/analytics/app.js +++ b/appengine/analytics/app.js @@ -58,10 +58,7 @@ app.get('/', async (req, res, next) => { 'Example label', '100' ); - res - .status(200) - .send('Event tracked.') - .end(); + res.status(200).send('Event tracked.').end(); } catch (error) { // This sample treats an event tracking error as a fatal error. Depending // on your application's needs, failing to track an event may not be diff --git a/appengine/building-an-app/update/test/server.test.js b/appengine/building-an-app/update/test/server.test.js index a58b94f9f4..6d6cee83c1 100755 --- a/appengine/building-an-app/update/test/server.test.js +++ b/appengine/building-an-app/update/test/server.test.js @@ -23,12 +23,12 @@ const cwd = path.join(__dirname, '../'); const requestObj = supertest(proxyquire(path.join(cwd, 'server'), {process})); -const stubConsole = function() { +const stubConsole = function () { sinon.stub(console, `error`); sinon.stub(console, `log`); }; -const restoreConsole = function() { +const restoreConsole = function () { console.log.restore(); console.error.restore(); }; @@ -40,7 +40,7 @@ it('should send greetings', async () => { await requestObj .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text, 'Hello from App Engine!'); }); }); @@ -49,7 +49,7 @@ it('should display form', async () => { await requestObj .get('/submit') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual( response.text.includes('textarea name="message" placeholder="Message"'), true @@ -64,7 +64,7 @@ it('should record message', async () => { message: 'sample-message', }) .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text, 'Thanks for your message!'); }); }); diff --git a/appengine/cloudsql/createTables.js b/appengine/cloudsql/createTables.js index 4b19d65ae0..09667558c5 100644 --- a/appengine/cloudsql/createTables.js +++ b/appengine/cloudsql/createTables.js @@ -34,7 +34,7 @@ prompt.get(FIELDS, async (err, config) => { // Create the "visits" table try { - await knex.schema.createTable('visits', table => { + await knex.schema.createTable('visits', (table) => { table.increments(); table.timestamp('timestamp'); table.string('userIp'); diff --git a/appengine/cloudsql/server.js b/appengine/cloudsql/server.js index 0b5b026a9b..f0174ca3a1 100644 --- a/appengine/cloudsql/server.js +++ b/appengine/cloudsql/server.js @@ -69,7 +69,7 @@ const insertVisit = (knex, visit) => { * @param {object} knex The Knex connection object. * @returns {Promise} */ -const getVisits = async knex => { +const getVisits = async (knex) => { const results = await knex .select('timestamp', 'userIp') .from('visits') @@ -77,7 +77,7 @@ const getVisits = async knex => { .limit(10); return results.map( - visit => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}` + (visit) => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}` ); }; diff --git a/appengine/cloudsql/test/createTables.test.js b/appengine/cloudsql/test/createTables.test.js index 09d4a01ec1..b79ac4bd28 100644 --- a/appengine/cloudsql/test/createTables.test.js +++ b/appengine/cloudsql/test/createTables.test.js @@ -56,13 +56,13 @@ const getSample = () => { }; }; -const stubConsole = function() { +const stubConsole = function () { /* eslint-disable no-console */ sinon.stub(console, `error`); sinon.stub(console, `log`); }; -const restoreConsole = function() { +const restoreConsole = function () { console.log.restore(); console.error.restore(); }; @@ -87,7 +87,7 @@ describe('gae_flex_mysql_create_tables', () => { exampleConfig ); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(sample.mocks.Knex.calledOnce); assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ { @@ -116,7 +116,7 @@ describe('gae_flex_mysql_create_tables', () => { prompt: sample.mocks.prompt, }); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(console.error.calledOnce); assert.ok(console.error.calledWith(error)); assert.ok(sample.mocks.Knex.notCalled); @@ -133,7 +133,7 @@ describe('gae_flex_mysql_create_tables', () => { knex: sample.mocks.Knex, prompt: sample.mocks.prompt, }); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(console.error.calledOnce); assert.ok( console.error.calledWith(`Failed to create 'visits' table:`, error) diff --git a/appengine/cloudsql/test/server.test.js b/appengine/cloudsql/test/server.test.js index a1e0205284..b93c7c86ec 100644 --- a/appengine/cloudsql/test/server.test.js +++ b/appengine/cloudsql/test/server.test.js @@ -99,7 +99,7 @@ describe('gae_flex_mysql_app', () => { await request(sample.app) .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text, expectedResult); }); }); @@ -113,7 +113,7 @@ describe('gae_flex_mysql_app', () => { await request(sample.app) .get('/') .expect(500) - .expect(response => { + .expect((response) => { assert.ok(response.text.includes(expectedResult)); }); }); @@ -127,7 +127,7 @@ describe('gae_flex_mysql_app', () => { await request(sample.app) .get('/') .expect(500) - .expect(response => { + .expect((response) => { assert.ok(response.text.includes(expectedResult)); }); }); diff --git a/appengine/cloudsql_postgresql/createTables.js b/appengine/cloudsql_postgresql/createTables.js index ad7ad11fd4..fc5030e604 100644 --- a/appengine/cloudsql_postgresql/createTables.js +++ b/appengine/cloudsql_postgresql/createTables.js @@ -34,7 +34,7 @@ prompt.get(FIELDS, async (err, config) => { // Create the "visits" table try { - await knex.schema.createTable('visits', table => { + await knex.schema.createTable('visits', (table) => { table.increments(); table.timestamp('timestamp'); table.string('userIp'); diff --git a/appengine/cloudsql_postgresql/server.js b/appengine/cloudsql_postgresql/server.js index a79bcb7d3f..ba06e57c4a 100644 --- a/appengine/cloudsql_postgresql/server.js +++ b/appengine/cloudsql_postgresql/server.js @@ -70,7 +70,7 @@ const insertVisit = (knex, visit) => { * @returns {Promise} */ -const getVisits = async knex => { +const getVisits = async (knex) => { const results = await knex .select('timestamp', 'userIp') .from('visits') @@ -78,7 +78,7 @@ const getVisits = async knex => { .limit(10); return results.map( - visit => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}` + (visit) => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}` ); }; diff --git a/appengine/cloudsql_postgresql/test/createTables.test.js b/appengine/cloudsql_postgresql/test/createTables.test.js index 095cd48679..545e95647a 100644 --- a/appengine/cloudsql_postgresql/test/createTables.test.js +++ b/appengine/cloudsql_postgresql/test/createTables.test.js @@ -56,12 +56,12 @@ const getSample = () => { }; }; -const stubConsole = function() { +const stubConsole = function () { sinon.stub(console, `error`); sinon.stub(console, `log`); }; -const restoreConsole = function() { +const restoreConsole = function () { console.log.restore(); console.error.restore(); }; @@ -86,7 +86,7 @@ describe('gae_flex_postgres_create_tables', () => { exampleConfig ); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(sample.mocks.Knex.calledOnce); assert.deepStrictEqual(sample.mocks.Knex.firstCall.args, [ { @@ -115,7 +115,7 @@ describe('gae_flex_postgres_create_tables', () => { prompt: sample.mocks.prompt, }); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(console.error.calledOnce); assert.ok(console.error.calledWith(error)); assert.ok(sample.mocks.Knex.notCalled); @@ -133,7 +133,7 @@ describe('gae_flex_postgres_create_tables', () => { prompt: sample.mocks.prompt, }); - await new Promise(r => setTimeout(r, 10)); + await new Promise((r) => setTimeout(r, 10)); assert.ok(console.error.calledOnce); assert.ok( console.error.calledWith(`Failed to create 'visits' table:`, error) diff --git a/appengine/cloudsql_postgresql/test/server.test.js b/appengine/cloudsql_postgresql/test/server.test.js index b34c8541d9..9b104dab6c 100644 --- a/appengine/cloudsql_postgresql/test/server.test.js +++ b/appengine/cloudsql_postgresql/test/server.test.js @@ -97,7 +97,7 @@ describe('gae_flex_postgres_app', () => { await request(sample.app) .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text, expectedResult); }); }); @@ -111,7 +111,7 @@ describe('gae_flex_postgres_app', () => { await request(sample.app) .get('/') .expect(500) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text.includes(expectedResult), true); }); }); @@ -125,7 +125,7 @@ describe('gae_flex_postgres_app', () => { await request(sample.app) .get('/') .expect(500) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text.includes(expectedResult), true); }); }); diff --git a/appengine/datastore/app.js b/appengine/datastore/app.js index a8ea6bb4ad..6634a182db 100644 --- a/appengine/datastore/app.js +++ b/appengine/datastore/app.js @@ -36,7 +36,7 @@ const datastore = new Datastore(); * * @param {object} visit The visit record to insert. */ -const insertVisit = visit => { +const insertVisit = (visit) => { return datastore.save({ key: datastore.key('visit'), data: visit, @@ -71,7 +71,7 @@ app.get('/', async (req, res, next) => { await insertVisit(visit); const [entities] = await getVisits(); const visits = entities.map( - entity => `Time: ${entity.timestamp}, AddrHash: ${entity.userIp}` + (entity) => `Time: ${entity.timestamp}, AddrHash: ${entity.userIp}` ); res .status(200) diff --git a/appengine/endpoints/test/app.test.js b/appengine/endpoints/test/app.test.js index d88e2d7ead..f8097c3747 100644 --- a/appengine/endpoints/test/app.test.js +++ b/appengine/endpoints/test/app.test.js @@ -38,18 +38,18 @@ const getSample = () => { }; }; -const stubConsole = function() { +const stubConsole = function () { sinon.stub(console, `error`); }; -const restoreConsole = function() { +const restoreConsole = function () { console.error.restore(); }; beforeEach(stubConsole); afterEach(restoreConsole); -it(`sets up the sample`, done => { +it(`sets up the sample`, (done) => { const sample = getSample(); assert.ok(sample.mocks.express.calledOnce); @@ -62,7 +62,7 @@ it(`should echo a message`, async () => { .post('/echo') .send({message: 'foo'}) .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.body.message, 'foo'); }); }); @@ -72,7 +72,7 @@ it(`should try to parse encoded info`, async () => { await request(sample.app) .get('/auth/info/googlejwt') .expect(200) - .expect(response => { + .expect((response) => { assert.deepStrictEqual(response.body, {id: 'anonymous'}); }); }); @@ -86,7 +86,7 @@ it(`should successfully parse encoded info`, async () => { Buffer.from(JSON.stringify({id: 'foo'})).toString('base64') ) .expect(200) - .expect(response => { + .expect((response) => { assert.deepStrictEqual(response.body, {id: 'foo'}); }); }); diff --git a/appengine/hello-world/flexible/app.js b/appengine/hello-world/flexible/app.js index ef16371e7a..4dcc07d20c 100644 --- a/appengine/hello-world/flexible/app.js +++ b/appengine/hello-world/flexible/app.js @@ -20,10 +20,7 @@ const express = require('express'); const app = express(); app.get('/', (req, res) => { - res - .status(200) - .send('Hello, world!') - .end(); + res.status(200).send('Hello, world!').end(); }); // Start the server diff --git a/appengine/hello-world/flexible/test/app.test.js b/appengine/hello-world/flexible/test/app.test.js index 142fa7ba00..8f5d29d786 100644 --- a/appengine/hello-world/flexible/test/app.test.js +++ b/appengine/hello-world/flexible/test/app.test.js @@ -4,16 +4,12 @@ const request = require('supertest'); describe('gae_flex_quickstart', () => { describe('GET /', () => { - it('should get 200', done => { - request(app) - .get('/') - .expect(200, done); + it('should get 200', (done) => { + request(app).get('/').expect(200, done); }); - it('should get Hello World', done => { - request(app) - .get('/') - .expect('Hello, world!', done); + it('should get Hello World', (done) => { + request(app).get('/').expect('Hello, world!', done); }); }); }); diff --git a/appengine/hello-world/standard/app.js b/appengine/hello-world/standard/app.js index deabd9e6f3..b9b499a45c 100644 --- a/appengine/hello-world/standard/app.js +++ b/appengine/hello-world/standard/app.js @@ -20,10 +20,7 @@ const express = require('express'); const app = express(); app.get('/', (req, res) => { - res - .status(200) - .send('Hello, world!') - .end(); + res.status(200).send('Hello, world!').end(); }); // Start the server diff --git a/appengine/hello-world/standard/test/app.test.js b/appengine/hello-world/standard/test/app.test.js index 6854fc36fa..5d58e14412 100644 --- a/appengine/hello-world/standard/test/app.test.js +++ b/appengine/hello-world/standard/test/app.test.js @@ -4,16 +4,12 @@ const request = require('supertest'); describe('gae_node_request_example', () => { describe('GET /', () => { - it('should get 200', done => { - request(app) - .get('/') - .expect(200, done); + it('should get 200', (done) => { + request(app).get('/').expect(200, done); }); - it('should get Hello World', done => { - request(app) - .get('/') - .expect('Hello, world!', done); + it('should get Hello World', (done) => { + request(app).get('/').expect('Hello, world!', done); }); }); }); diff --git a/appengine/metadata/flexible/server.js b/appengine/metadata/flexible/server.js index a7b56c5356..187e68ee9a 100644 --- a/appengine/metadata/flexible/server.js +++ b/appengine/metadata/flexible/server.js @@ -45,10 +45,7 @@ const getExternalIp = async () => { app.get('/', async (req, res, next) => { try { const externalIp = await getExternalIp(); - res - .status(200) - .send(`External IP: ${externalIp}`) - .end(); + res.status(200).send(`External IP: ${externalIp}`).end(); } catch (err) { next(err); } diff --git a/appengine/metadata/standard/server.js b/appengine/metadata/standard/server.js index 2a7ee4616c..09cd4bd5b1 100644 --- a/appengine/metadata/standard/server.js +++ b/appengine/metadata/standard/server.js @@ -37,10 +37,7 @@ app.get('/', async (req, res, next) => { try { const response = await getProjectId(); const projectId = response.body; - res - .status(200) - .send(`Project ID: ${projectId}`) - .end(); + res.status(200).send(`Project ID: ${projectId}`).end(); } catch (error) { if (error && error.statusCode && error.statusCode !== 200) { console.log('Error while talking to metadata server.'); diff --git a/appengine/pubsub/test/app.test.js b/appengine/pubsub/test/app.test.js index f5accfb133..1dbd56624d 100644 --- a/appengine/pubsub/test/app.test.js +++ b/appengine/pubsub/test/app.test.js @@ -72,7 +72,7 @@ describe('gae_flex_pubsub_index', () => { .type('form') .send({payload: payload}) .expect(200) - .expect(response => { + .expect((response) => { assert(new RegExp(/Message \d* sent/).test(response.text)); }); }); @@ -81,7 +81,7 @@ describe('gae_flex_pubsub_index', () => { await requestObj .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert( new RegExp(/Messages received by this instance/).test(response.text) ); @@ -103,10 +103,7 @@ describe('gae_flex_pubsub_push', () => { }); it('should check for verification token on incoming Pub/Sub messages', async () => { - await requestObj - .post('/pubsub/push') - .field('payload', payload) - .expect(400); + await requestObj.post('/pubsub/push').field('payload', payload).expect(400); }); }); @@ -135,7 +132,7 @@ describe('gae_flex_pubsub_auth_push', () => { await requestObj .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert(response.text.includes(payload)); }); }); diff --git a/appengine/redis/server.js b/appengine/redis/server.js index 698a43d7f9..f6d3a408d8 100644 --- a/appengine/redis/server.js +++ b/appengine/redis/server.js @@ -21,10 +21,7 @@ const nconf = require('nconf'); // read in keys and secrets. You can store these in a variety of ways. // I like to use a keys.json file that is in the .gitignore file, // but you can also store them in environment variables -nconf - .argv() - .env() - .file('keys.json'); +nconf.argv().env().file('keys.json'); // [START gae_flex_node_redis] // Connect to a redis server provisioned over at @@ -38,7 +35,7 @@ const client = redis return_buffers: true, } ) - .on('error', err => console.error('ERR:REDIS:', err)); + .on('error', (err) => console.error('ERR:REDIS:', err)); // [END gae_flex_node_redis]] // Create a simple little server. @@ -58,7 +55,7 @@ http return; } - data.forEach(ip => { + data.forEach((ip) => { iplist += `${ip}; `; }); diff --git a/appengine/sendgrid/test/app.test.js b/appengine/sendgrid/test/app.test.js index afbc3f54ac..71206688da 100644 --- a/appengine/sendgrid/test/app.test.js +++ b/appengine/sendgrid/test/app.test.js @@ -11,7 +11,7 @@ describe('gae_flex_sendgrid', () => { await request .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert(response.text.includes('Hello World!')); }); }); @@ -22,7 +22,7 @@ describe('gae_flex_sendgrid', () => { .type('form') .send({email: 'testuser@google.com'}) .expect(200) - .expect(response => { + .expect((response) => { assert(response.text.includes('Email sent!')); }); }); diff --git a/appengine/storage/flexible/app.js b/appengine/storage/flexible/app.js index 34aa709613..d3710b2407 100644 --- a/appengine/storage/flexible/app.js +++ b/appengine/storage/flexible/app.js @@ -64,7 +64,7 @@ app.post('/upload', multer.single('file'), (req, res, next) => { const blob = bucket.file(req.file.originalname); const blobStream = blob.createWriteStream(); - blobStream.on('error', err => { + blobStream.on('error', (err) => { next(err); }); diff --git a/appengine/storage/flexible/system-test/app.test.js b/appengine/storage/flexible/system-test/app.test.js index c2c8c323b4..54cba6fa8e 100644 --- a/appengine/storage/flexible/system-test/app.test.js +++ b/appengine/storage/flexible/system-test/app.test.js @@ -53,7 +53,7 @@ it('should load', async () => { await requestObj .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual( new RegExp(//).test(response.text), true @@ -66,7 +66,7 @@ it('should upload a file', async () => { .post('/upload') .attach('file', path.join(__dirname, 'resources/test.txt')) .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual( response.text, `https://storage.googleapis.com/${bucketName}/test.txt` diff --git a/appengine/storage/standard/app.js b/appengine/storage/standard/app.js index 113f3f3948..c53c860288 100644 --- a/appengine/storage/standard/app.js +++ b/appengine/storage/standard/app.js @@ -66,7 +66,7 @@ app.post('/upload', multer.single('file'), (req, res, next) => { resumable: false, }); - blobStream.on('error', err => { + blobStream.on('error', (err) => { next(err); }); diff --git a/appengine/storage/standard/system-test/app.test.js b/appengine/storage/standard/system-test/app.test.js index c2c8c323b4..54cba6fa8e 100644 --- a/appengine/storage/standard/system-test/app.test.js +++ b/appengine/storage/standard/system-test/app.test.js @@ -53,7 +53,7 @@ it('should load', async () => { await requestObj .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual( new RegExp(//).test(response.text), true @@ -66,7 +66,7 @@ it('should upload a file', async () => { .post('/upload') .attach('file', path.join(__dirname, 'resources/test.txt')) .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual( response.text, `https://storage.googleapis.com/${bucketName}/test.txt` diff --git a/appengine/twilio/app.js b/appengine/twilio/app.js index f55a78b335..0fa6a9d553 100644 --- a/appengine/twilio/app.js +++ b/appengine/twilio/app.js @@ -44,10 +44,7 @@ app.post('/call/receive', (req, res) => { twiml.say('Hello from Google App Engine.'); - res - .status(200) - .contentType('text/xml') - .send(twiml.toString()); + res.status(200).contentType('text/xml').send(twiml.toString()); }); // [END gae_flex_twilio_receive_call] @@ -83,10 +80,7 @@ app.post('/sms/receive', bodyParser, (req, res) => { const twiml = new twilio.twiml.MessagingResponse(); twiml.message(`Hello, ${sender}, you said: ${body}`); - res - .status(200) - .contentType('text/xml') - .send(twiml.toString()); + res.status(200).contentType('text/xml').send(twiml.toString()); }); // [END gae_flex_twilio_receive_sms] diff --git a/appengine/twilio/test/app.test.js b/appengine/twilio/test/app.test.js index dcb89b5cc2..ac45e6d080 100644 --- a/appengine/twilio/test/app.test.js +++ b/appengine/twilio/test/app.test.js @@ -60,7 +60,7 @@ describe('gae_flex_twilio_send_sms', () => { .get('/sms/send') .query({to: 1234}) .expect(200) - .expect(response => { + .expect((response) => { assert.strictEqual(response.text, 'Message sent.'); }); }); diff --git a/appengine/websockets/app.js b/appengine/websockets/app.js index 6b9875c8c6..58eb0c167b 100644 --- a/appengine/websockets/app.js +++ b/appengine/websockets/app.js @@ -25,8 +25,8 @@ app.get('/', (req, res) => { res.render('index.pug'); }); -io.on('connection', socket => { - socket.on('chat message', msg => { +io.on('connection', (socket) => { + socket.on('chat message', (msg) => { io.emit('chat message', msg); }); }); diff --git a/appengine/websockets/test/index.test.js b/appengine/websockets/test/index.test.js index f1d3c2216b..aa3f64e7e7 100644 --- a/appengine/websockets/test/index.test.js +++ b/appengine/websockets/test/index.test.js @@ -40,7 +40,7 @@ describe('appengine_websockets_app', () => { document.querySelector('button').click(); }); - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); const itemText = await browserPage.evaluate( () => document.querySelector('li').textContent diff --git a/auth/auth.js b/auth/auth.js index ea9d173e51..43318a5edc 100644 --- a/auth/auth.js +++ b/auth/auth.js @@ -36,7 +36,7 @@ const authCloudImplicit = async () => { const [buckets] = results; console.log('Buckets:'); - buckets.forEach(bucket => { + buckets.forEach((bucket) => { console.log(bucket.name); }); } catch (err) { @@ -62,7 +62,7 @@ const authCloudExplicit = async ({projectId, keyFilename}) => { const [buckets] = await storage.getBuckets(); console.log('Buckets:'); - buckets.forEach(bucket => { + buckets.forEach((bucket) => { console.log(bucket.name); }); } catch (err) { diff --git a/cloud-sql/mysql/mysql/server.js b/cloud-sql/mysql/mysql/server.js index f8091b9a4a..a7b9485ff0 100644 --- a/cloud-sql/mysql/mysql/server.js +++ b/cloud-sql/mysql/mysql/server.js @@ -130,10 +130,7 @@ app.post('/', async (req, res) => { const timestamp = new Date(); if (!team || (team !== 'TABS' && team !== 'SPACES')) { - res - .status(400) - .send('Invalid team specified.') - .end(); + res.status(400).send('Invalid team specified.').end(); } // [START cloud_sql_mysql_mysql_connection] @@ -157,10 +154,7 @@ app.post('/', async (req, res) => { } // [END cloud_sql_mysql_mysql_connection] - res - .status(200) - .send(`Successfully voted for ${team} at ${timestamp}`) - .end(); + res.status(200).send(`Successfully voted for ${team} at ${timestamp}`).end(); }); const PORT = process.env.PORT || 8080; diff --git a/cloud-sql/mysql/mysql/test/server.test.js b/cloud-sql/mysql/mysql/test/server.test.js index 82dd88dec9..23a9b6615f 100644 --- a/cloud-sql/mysql/mysql/test/server.test.js +++ b/cloud-sql/mysql/mysql/test/server.test.js @@ -30,9 +30,7 @@ stubMysql.createPool.returns(poolStub); const server = require('../server.js'); it('check index page', async () => { - const response = await request(server) - .get('/') - .timeout(1000); + const response = await request(server).get('/').timeout(1000); assert.strictEqual(response.status, 200); }); diff --git a/cloud-sql/postgres/knex/createTable.js b/cloud-sql/postgres/knex/createTable.js index 4406631f23..07aaf96ecf 100644 --- a/cloud-sql/postgres/knex/createTable.js +++ b/cloud-sql/postgres/knex/createTable.js @@ -16,14 +16,14 @@ const Knex = require('knex'); -const createTable = async config => { +const createTable = async (config) => { // Connect to the database config.host = `/cloudsql/${config.connectionName}`; const knex = Knex({client: 'pg', connection: config}); // Create the "votes" table try { - await knex.schema.createTable('votes', table => { + await knex.schema.createTable('votes', (table) => { table.bigIncrements('vote_id').notNull(); table.timestamp('time_cast').notNull(); table.specificType('candidate', 'CHAR(6) NOT NULL'); diff --git a/cloud-sql/postgres/knex/server.js b/cloud-sql/postgres/knex/server.js index a4aaae2bd6..5b7388c855 100644 --- a/cloud-sql/postgres/knex/server.js +++ b/cloud-sql/postgres/knex/server.js @@ -126,7 +126,7 @@ const insertVote = async (knex, vote) => { * @param {object} knex The Knex connection object. * @returns {Promise} */ -const getVotes = async knex => { +const getVotes = async (knex) => { return await knex .select('candidate', 'time_cast') .from('votes') @@ -143,13 +143,11 @@ const getVotes = async knex => { * @returns {Promise} */ const getVoteCount = async (knex, candidate) => { - return await knex('votes') - .count('vote_id') - .where('candidate', candidate); + return await knex('votes').count('vote_id').where('candidate', candidate); }; app.get('/', (req, res) => { - (async function() { + (async function () { // Query the total count of "TABS" from the database. const tabsResult = await getVoteCount(knex, 'TABS'); const tabsTotalVotes = parseInt(tabsResult[0].count); @@ -193,10 +191,7 @@ app.post('/', async (req, res) => { const timestamp = new Date(); if (!team || (team !== 'TABS' && team !== 'SPACES')) { - res - .status(400) - .send('Invalid team specified.') - .end(); + res.status(400).send('Invalid team specified.').end(); return; } @@ -217,10 +212,7 @@ app.post('/', async (req, res) => { .end(); return; } - res - .status(200) - .send(`Successfully voted for ${team} at ${timestamp}`) - .end(); + res.status(200).send(`Successfully voted for ${team} at ${timestamp}`).end(); }); const PORT = process.env.PORT || 8080; diff --git a/cloud-sql/postgres/knex/test/createTable.test.js b/cloud-sql/postgres/knex/test/createTable.test.js index aa2e71ed84..a02aa67f31 100644 --- a/cloud-sql/postgres/knex/test/createTable.test.js +++ b/cloud-sql/postgres/knex/test/createTable.test.js @@ -41,7 +41,7 @@ before(async () => { } }); -it('should create a table', done => { +it('should create a table', (done) => { exec( `node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`, {cwd}, @@ -52,7 +52,7 @@ it('should create a table', done => { ); }); -it('should handle existing tables', done => { +it('should handle existing tables', (done) => { exec( `node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`, {cwd}, diff --git a/cloud-sql/postgres/knex/test/server.test.js b/cloud-sql/postgres/knex/test/server.test.js index 0b3b726ae5..8b16e62977 100644 --- a/cloud-sql/postgres/knex/test/server.test.js +++ b/cloud-sql/postgres/knex/test/server.test.js @@ -30,7 +30,7 @@ it('should display the default page', async () => { await request(server) .get('/') .expect(200) - .expect(response => { + .expect((response) => { assert.ok(response.text.includes('Tabs VS Spaces')); }); }); @@ -41,7 +41,7 @@ it('should handle insert error', async () => { await request(server) .post('/') .expect(400) - .expect(response => { + .expect((response) => { assert.ok(response.text.includes(expectedResult)); }); }); diff --git a/cloud-tasks/app/createTask.js b/cloud-tasks/app/createTask.js index 49186094c2..cbe7ce51ff 100644 --- a/cloud-tasks/app/createTask.js +++ b/cloud-tasks/app/createTask.js @@ -17,7 +17,7 @@ // [START cloud_tasks_app_create_task] const MAX_SCHEDULE_LIMIT = 30 * 60 * 60 * 24; // Represents 30 days in seconds. -const createHttpTaskWithToken = async function( +const createHttpTaskWithToken = async function ( project = 'my-project-id', // Your GCP Project id queue = 'my-queue', // Name of your Queue location = 'us-central1', // The GCP region of your queue diff --git a/cloud-tasks/function/index.js b/cloud-tasks/function/index.js index 1102afff3e..159c98818b 100644 --- a/cloud-tasks/function/index.js +++ b/cloud-tasks/function/index.js @@ -76,7 +76,7 @@ exports.sendEmail = async (req, res) => { // [END cloud_tasks_func] // Function creates an HTML postcard with message. -const postcardHTML = function(to_name, from_name) { +const postcardHTML = function (to_name, from_name) { return `