mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 14:12:40 +00:00
Trimming Google APIs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable max-lines */
|
||||
const _ = require('lodash');
|
||||
const { google } = require('googleapis');
|
||||
const drive = require('@googleapis/drive');
|
||||
const { nanoid } = require('nanoid');
|
||||
const token = require('./token.js');
|
||||
const config = require('./config.js');
|
||||
@@ -14,7 +14,7 @@ if(!config.get('service_account')){
|
||||
config.get('service_account');
|
||||
|
||||
try {
|
||||
serviceAuth = google.auth.fromJSON(keys);
|
||||
serviceAuth = drive.auth.fromJSON(keys);
|
||||
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
@@ -22,8 +22,6 @@ if(!config.get('service_account')){
|
||||
}
|
||||
}
|
||||
|
||||
google.options({ auth: serviceAuth || config.get('google_api_key') });
|
||||
|
||||
const GoogleActions = {
|
||||
|
||||
authCheck : (account, res, updateTokens=true)=>{
|
||||
@@ -33,7 +31,7 @@ const GoogleActions = {
|
||||
throw (err);
|
||||
}
|
||||
|
||||
const oAuth2Client = new google.auth.OAuth2(
|
||||
const oAuth2Client = new drive.auth.OAuth2(
|
||||
config.get('google_client_id'),
|
||||
config.get('google_client_secret'),
|
||||
'/auth/google/redirect'
|
||||
@@ -60,7 +58,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
getGoogleFolder : async (auth)=>{
|
||||
const drive = google.drive({ version: 'v3', auth });
|
||||
const drive = drive({ version: 'v3', auth });
|
||||
|
||||
fileMetadata = {
|
||||
'name' : 'Homebrewery',
|
||||
@@ -97,7 +95,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
listGoogleBrews : async (auth)=>{
|
||||
const drive = google.drive({ version: 'v3', auth });
|
||||
const drive = drive({ version: 'v3', auth });
|
||||
|
||||
const obj = await drive.files.list({
|
||||
pageSize : 1000,
|
||||
@@ -136,7 +134,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
updateGoogleBrew : async (brew)=>{
|
||||
const drive = google.drive({ version: 'v3' });
|
||||
const drive = drive({ version: 'v3' });
|
||||
|
||||
await drive.files.update({
|
||||
fileId : brew.googleId,
|
||||
@@ -167,7 +165,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
newGoogleBrew : async (auth, brew)=>{
|
||||
const drive = google.drive({ version: 'v3', auth });
|
||||
const drive = drive({ version: 'v3', auth });
|
||||
|
||||
const media = {
|
||||
mimeType : 'text/plain',
|
||||
@@ -218,7 +216,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
getGoogleBrew : async (id, accessId, accessType)=>{
|
||||
const drive = google.drive({ version: 'v3' });
|
||||
const drive = drive({ version: 'v3' });
|
||||
|
||||
const obj = await drive.files.get({
|
||||
fileId : id,
|
||||
@@ -274,7 +272,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
deleteGoogleBrew : async (auth, id, accessId)=>{
|
||||
const drive = google.drive({ version: 'v3', auth });
|
||||
const drive = drive({ version: 'v3', auth });
|
||||
|
||||
const obj = await drive.files.get({
|
||||
fileId : id,
|
||||
@@ -300,7 +298,7 @@ const GoogleActions = {
|
||||
},
|
||||
|
||||
increaseView : async (id, accessId, accessType, brew)=>{
|
||||
const drive = google.drive({ version: 'v3' });
|
||||
const drive = drive({ version: 'v3' });
|
||||
|
||||
await drive.files.update({
|
||||
fileId : brew.googleId,
|
||||
|
||||
Reference in New Issue
Block a user