diff --git a/src/pages/api/experimental/batch.ts b/src/pages/api/experimental/batch.ts deleted file mode 100644 index 126a0ef..0000000 --- a/src/pages/api/experimental/batch.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next"; -import drive from "@utils/driveClient"; -import config from "@/config/site.config"; -import { google } from "googleapis"; - -export default async function handler( - request: NextApiRequest, - response: NextApiResponse, -) { - const _start: number = Date.now(); - try { - const ids = [ - "1JARq3gOODQeOLd2DwT5qZjZAOtO-8Jvl", - "1CSKTtgXunrSHYRRp8FyMXYpNP6xK1iju", - "1NK-J1QIf0vuGnDIEHXBG2-9jXP6sKCuN", - ]; - - function getFile(id: string) { - return new Promise((resolve, reject) => { - drive.files.get( - { - fileId: id, - fields: "id, name, mimeType, parents", - }, - (error, response) => { - if (error) reject(error); - resolve(response); - }, - ); - }); - } - - const batch = google.batch("v1"); - for (const id of ids) { - // @ts-ignore - batch.add(getFile(id)); - } - - // @ts-ignore - const res = await batch.execute(); - - const _end: number = Date.now(); - return response.status(200).json({ - success: true, - timestamp: new Date().toISOString(), - duration: _end - _start, - res, - }); - } catch (error: any) { - return response.status(500).json({ - success: false, - timestamp: new Date().toISOString(), - error: error, - }); - } -} diff --git a/src/pages/api/experimental/getAllParents.ts b/src/pages/api/experimental/getAllParents.ts deleted file mode 100644 index 6154a05..0000000 --- a/src/pages/api/experimental/getAllParents.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next"; -import drive from "@utils/driveClient"; -import config from "@/config/site.config"; - -export default async function handler( - request: NextApiRequest, - response: NextApiResponse, -) { - const _start: number = Date.now(); - try { - const id = "1JARq3gOODQeOLd2DwT5qZjZAOtO-8Jvl"; - const parents: string[] = []; - const getFile = await drive.files.get({ - fileId: id as string, - fields: "id, name, mimeType, parents", - }); - - let parent = getFile.data.parents?.[0]; - - while (parent) { - console.log("Searching parent for: ", parent); - const getParent = await drive.files.get({ - fileId: parent as string, - fields: "id, name, mimeType, parents", - }); - parents.push(getParent.data.id as string); - if (getParent.data.id === config.files.rootFolder) break; - parent = getParent.data.parents?.[0]; - console.log("Parent found: ", parent); - } - - const searchPassword = await drive.files.list({ - q: "name = '.password' and 'me' in owners and trashed = false", - fields: "files(id, name, mimeType, parents)", - }); - let passwordFile = null; - if (searchPassword.data.files?.length) { - passwordFile = searchPassword.data.files.filter((file) => - parents.includes(file.parents?.[0] as string), - ); - } - - const _end: number = Date.now(); - return response.status(200).json({ - success: true, - timestamp: new Date().toISOString(), - duration: _end - _start, - parents: parents, - passwordFile: passwordFile, - }); - } catch (error: any) { - return response.status(500).json({ - success: false, - timestamp: new Date().toISOString(), - error: error, - }); - } -}