Skip to content

Commit

Permalink
Merge branch 'master' into fhinkel-axios
Browse files Browse the repository at this point in the history
  • Loading branch information
fhinkel authored Oct 30, 2020
2 parents 216ef26 + 6db5736 commit e80484b
Show file tree
Hide file tree
Showing 242 changed files with 1,367 additions and 1,295 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ test/fixtures
build/
docs/
protos/
run/idp-sql/
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./node_modules/gts/",
"env": {
"mocha": true
},
"rules": {
"node/no-missing-require": ["off"],
"node/no-unpublished-require": ["off"],
"no-unused-vars": ["off"],
"node/no-deprecated-api": ["off"],
"no-process-exit": ["off"]
}
}
4 changes: 0 additions & 4 deletions .estlintrc.json

This file was deleted.

4 changes: 3 additions & 1 deletion appengine/analytics/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const trackEvent = (category, action, label, value) => {
ev: value,
};

return fetch('http://www.google-analytics.com/debug/collect', { params: data });
return axios.get('http://www.google-analytics.com/debug/collect', {
params: data,
});
};

app.get('/', async (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion appengine/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
},
"devDependencies": {
"mocha": "^8.0.0",
"supertest": "^5.0.0"
"supertest": "^6.0.0"
}
}
2 changes: 1 addition & 1 deletion appengine/building-an-app/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"devDependencies": {
"mocha": "^8.0.0",
"supertest": "^5.0.0",
"supertest": "^6.0.0",
"proxyquire": "^2.1.3"
}
}
2 changes: 1 addition & 1 deletion appengine/building-an-app/update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"mocha": "^8.0.0",
"sinon": "^9.0.0",
"supertest": "^5.0.0",
"supertest": "^6.0.0",
"proxyquire": "^2.1.3"
}
}
2 changes: 1 addition & 1 deletion appengine/building-an-app/update/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// [START app]
const express = require('express');
const bodyParser = require('body-parser');
const path = require(`path`);
const path = require('path');

const app = express();

Expand Down
14 changes: 8 additions & 6 deletions appengine/building-an-app/update/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const cwd = path.join(__dirname, '../');
const requestObj = supertest(proxyquire(path.join(cwd, 'server'), {process}));

const stubConsole = function () {
sinon.stub(console, `error`);
sinon.stub(console, `log`);
sinon.stub(console, 'error');
sinon.stub(console, 'log');
};

const restoreConsole = function () {
Expand All @@ -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!');
});
});
Expand All @@ -50,9 +50,11 @@ describe('add_display_form', () => {
await requestObj
.get('/submit')
.expect(200)
.expect((response) => {
.expect(response => {
assert.strictEqual(
response.text.includes('textarea name="message" placeholder="Message"'),
response.text.includes(
'textarea name="message" placeholder="Message"'
),
true
);
});
Expand All @@ -67,7 +69,7 @@ describe('add_post_handler enable_parser', () => {
message: 'sample-message',
})
.expect(200)
.expect((response) => {
.expect(response => {
assert.strictEqual(response.text, 'Thanks for your message!');
});
});
Expand Down
6 changes: 3 additions & 3 deletions appengine/cloudsql/createTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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');
});

console.log(`Successfully created 'visits' table.`);
console.log("Successfully created 'visits' table.");
} catch (err) {
console.error(`Failed to create 'visits' table:`, err);
console.error("Failed to create 'visits' table:", err);
} finally {
if (knex) {
knex.destroy();
Expand Down
2 changes: 1 addition & 1 deletion appengine/cloudsql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mocha": "^8.0.0",
"proxyquire": "^2.1.0",
"sinon": "^9.0.0",
"supertest": "^5.0.0",
"supertest": "^6.0.0",
"wait-port": "^0.2.7"
}
}
4 changes: 2 additions & 2 deletions appengine/cloudsql/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ 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')
.orderBy('timestamp', 'desc')
.limit(10);

return results.map(
(visit) => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}`
visit => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}`
);
};

Expand Down
14 changes: 7 additions & 7 deletions appengine/cloudsql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const getSample = () => {

const stubConsole = function () {
/* eslint-disable no-console */
sinon.stub(console, `error`);
sinon.stub(console, `log`);
sinon.stub(console, 'error');
sinon.stub(console, 'log');
};

const restoreConsole = function () {
Expand All @@ -73,7 +73,7 @@ afterEach(restoreConsole);
describe('gae_flex_mysql_create_tables', () => {
it('should create a table', async () => {
const sample = getSample();
const expectedResult = `Successfully created 'visits' table.`;
const expectedResult = "Successfully created 'visits' table.";

proxyquire(SAMPLE_PATH, {
knex: sample.mocks.Knex,
Expand All @@ -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, [
{
Expand Down Expand Up @@ -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);
Expand All @@ -133,10 +133,10 @@ 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)
console.error.calledWith("Failed to create 'visits' table:", error)
);
assert.ok(sample.mocks.knex.destroy.calledOnce);
});
Expand Down
6 changes: 3 additions & 3 deletions appengine/cloudsql/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand All @@ -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));
});
});
Expand All @@ -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));
});
});
Expand Down
6 changes: 3 additions & 3 deletions appengine/cloudsql_postgresql/createTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ 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');
});

console.log(`Successfully created 'visits' table.`);
console.log("Successfully created 'visits' table.");
return knex.destroy();
} catch (err) {
console.error(`Failed to create 'visits' table:`, err);
console.error("Failed to create 'visits' table:", err);
if (knex) {
knex.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion appengine/cloudsql_postgresql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"mocha": "^8.0.0",
"proxyquire": "^2.1.0",
"sinon": "^9.0.0",
"supertest": "^5.0.0"
"supertest": "^6.0.0"
}
}
4 changes: 2 additions & 2 deletions appengine/cloudsql_postgresql/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ const insertVisit = (knex, visit) => {
* @returns {Promise}
*/

const getVisits = async (knex) => {
const getVisits = async knex => {
const results = await knex
.select('timestamp', 'userIp')
.from('visits')
.orderBy('timestamp', 'desc')
.limit(10);

return results.map(
(visit) => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}`
visit => `Time: ${visit.timestamp}, AddrHash: ${visit.userIp}`
);
};

Expand Down
14 changes: 7 additions & 7 deletions appengine/cloudsql_postgresql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const getSample = () => {
};

const stubConsole = function () {
sinon.stub(console, `error`);
sinon.stub(console, `log`);
sinon.stub(console, 'error');
sinon.stub(console, 'log');
};

const restoreConsole = function () {
Expand All @@ -72,7 +72,7 @@ afterEach(restoreConsole);
describe('gae_flex_postgres_create_tables', () => {
it('should create a table', async () => {
const sample = getSample();
const expectedResult = `Successfully created 'visits' table.`;
const expectedResult = "Successfully created 'visits' table.";

proxyquire(SAMPLE_PATH, {
knex: sample.mocks.Knex,
Expand All @@ -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, [
{
Expand Down Expand Up @@ -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);
Expand All @@ -133,10 +133,10 @@ 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)
console.error.calledWith("Failed to create 'visits' table:", error)
);
assert.ok(sample.mocks.knex.destroy.calledOnce);
});
Expand Down
6 changes: 3 additions & 3 deletions appengine/cloudsql_postgresql/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand All @@ -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);
});
});
Expand All @@ -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);
});
});
Expand Down
4 changes: 2 additions & 2 deletions appengine/datastore/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion appengine/datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
},
"devDependencies": {
"mocha": "^8.0.0",
"supertest": "^5.0.0"
"supertest": "^6.0.0"
}
}
Loading

0 comments on commit e80484b

Please sign in to comment.