Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const GOOGLE_CLIENT_SECRET = process.env.GOOGLE_SHEETS_CLIENT_SECRET;
const API_BASE_URL = process.env.API_BASE_URL;
/* eslint-disable no-unused-vars */
// NOTE these variables will be used once the OAuth strategy begins, not before
const CALLBACK_URL = process.env.GOOGLE_SHEETS_URL;
const PROFILE_ID = process.env.GOOGLE_SHEETS_PROFILE_ID;

app.use(morgan('combined'));
Expand Down Expand Up @@ -54,13 +53,13 @@ passport.use(new GoogleStrategy({
callbackURL: `${API_BASE_URL}/auth/google/callback`,

},
((accessToken, refreshToken, profile, done) => {
process.env.TKN = accessToken;
process.env.PROFILE_ID = profile.id;
process.env.USERNAME = profile.displayName;
((accessToken, refreshToken, profile, done) => {
process.env.TKN = accessToken;
process.env.PROFILE_ID = profile.id;
process.env.USERNAME = profile.displayName;

done(null, profile);
}),
done(null, profile);
}),
));

app.get('/auth/google',
Expand Down
6 changes: 3 additions & 3 deletions src/models/Sheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Sheets {
getAllUserSheets() {
return fetch(this.spreadSheetUrl)
.then(getJson)
.then(response =>
response.sheets.map(sheet => sheet.properties.title))
.then(sheetNames => sheetNames.map(sheetName => fetch(`https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${sheetName}!A1:ZZ?access_token=${process.env.TKN}`)))
.then(response => response.sheets.map(sheet => sheet.properties.title))
.then(sheetNames => sheetNames.map(sheetName => fetch(`https://sheets.googleapis.com/v4/spreadsheets/${this.spreadsheetId}/values/${sheetName}!A1:ZZ?access_token=${process.env.TKN}`),
))
.then(promiseArray => Promise.all(promiseArray))
.then(responses => responses.map(response => response.json()))
.then(responses => Promise.all(responses))
Expand Down
2 changes: 1 addition & 1 deletion src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const schema = buildSchema(`
}

type Sheet {
sheetName: String
range: String
majorDimension: String
values: [[String]]
sheetName: String
}

type Query {
Expand Down