codegasms / flux

A complete file management utility
https://flux.codegasms.com
4 stars 2 forks source link

Import/Export to Google Drive #108

Open aahnik opened 1 month ago

aahnik commented 1 month ago

As we plan to do integrations with several external services, we can write all our integrations inside the same folder.

Let's start by creating a new nest js module integrations (suggest a better name ?)

Folder structure

We can create an integrations module and structure it by having folders like controllers, services

Inside them, we can have gdrive.controller.ts and gdrive.service.ts, and in the future a controller and service for every integration we do.

API endpoints

  1. integrations/gdrive/authorize to authorize our application (via Google OAuth consent screen + Google Drive access scope, so we are authorized on behalf of a user. We need to save the tokens, and brainstorm about a secure token storage strategy, or one-time permissions ? This would add a new Google Drive connection. The user might not give us access to their entire drive, but a specific folder of their drive, and our work will be under that folder.
  2. integrations/gdrive/connections (multiple CRUD verbs, but same route) See a list of connected Google Drive accounts, edit permissions, or delete them.
  3. integrations/gdrive/export to initiate the process of writing files in space to the user's Google Drive. this is a long-running task and should be added to our bullmq. This API endpoint should accept parameters such as spacePath, Google drive path, and google account ID ( in case the user has multiple connected accounts)
  4. integrations/gdrive/import, same as above, but files from the drive will be downloaded, and put into the user's space

Points to think

  1. should points 2 and 3 be merged into a single endpoint?
  2. (add challenges/design dilemmas here)

Official Google Drive API