0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Merge pull request #1282 from naturalcrit/ReduceRedundancyInServerJS

[WIP] Move common Server.js logic into functions
This commit is contained in:
Trevor Buckner
2021-03-27 23:43:11 -04:00
committed by GitHub
4 changed files with 101 additions and 179 deletions

View File

@@ -240,6 +240,7 @@ GoogleActions = {
},
readFileMetadata : async (auth, id, accessId, accessType)=>{
const drive = google.drive({ version: 'v3', auth: auth });
const obj = await drive.files.get({
@@ -248,7 +249,7 @@ GoogleActions = {
})
.catch((err)=>{
console.log('Error loading from Google');
console.error(err);
throw (err);
return;
});
@@ -345,7 +346,10 @@ GoogleActions = {
increaseView : async (id, accessId, accessType, brew)=>{
//service account because this is modifying another user's file properties
//so we need extended scope
const keys = JSON.parse(config.get('service_account'));
const keys = typeof(config.get('service_account')) == 'string' ?
JSON.parse(config.get('service_account')) :
config.get('service_account');
const auth = google.auth.fromJSON(keys);
auth.scopes = ['https://www.googleapis.com/auth/drive'];