Skip to content

Commit

Permalink
refactor: No more data.data.data (#1474)
Browse files Browse the repository at this point in the history
* refactor: No more data.data.data

* tests: fix tests
  • Loading branch information
grant authored Sep 17, 2019
1 parent de043b5 commit 9dc0fa0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions functions/log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ function getMetrics(callback) {

// [START functions_log_stackdriver]
exports.processLogEntry = data => {
// Node 6: data.data === Node 8+: data
const dataBuffer = Buffer.from(data.data.data || data.data, 'base64');
const dataBuffer = Buffer.from(data.data, 'base64');

const logEntry = JSON.parse(dataBuffer.toString('ascii')).protoPayload;
console.log(`Method: ${logEntry.methodName}`);
Expand Down
4 changes: 1 addition & 3 deletions functions/log/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ it('processLogEntry: should process log entry', () => {
});

const data = {
data: {
data: Buffer.from(json, 'ascii'),
},
data: Buffer.from(json, 'ascii'),
};

sample.program.processLogEntry(data);
Expand Down

0 comments on commit 9dc0fa0

Please sign in to comment.