npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-drive-sync-directory

v1.0.1

Published

A Node.js package that allows you to easily synchronize a directory with Google Drive. This package handles authentication with Google Drive using OAuth2 and monitors a specified directory for new files. When new files are detected, they are automatically

Downloads

6

Readme

Google Drive Sync Module

Introduction

The Google Drive Sync Module is a Node.js package designed to simplify the process of synchronizing a local directory with a Google Drive folder. It provides functionality to monitor a specified directory for new files and automatically upload them to a designated Google Drive folder. This README guide will walk you through the setup, configuration, and usage of the module.

Installation

To install the Google Drive Sync Module, ensure you have Node.js installed on your system. You can then install the package via npm:

npm install google-drive-sync-directory

Setting up Google API Credentials

Before using the module, you need to set up the necessary credentials to access Google APIs. Follow these steps to obtain and configure the required credentials:

  1. Google API Console: Go to the Google API Console and create or select a project.

  2. Enable APIs: Enable the Google Drive API and any other required APIs for your project.

  3. Create OAuth Client ID: Navigate to the "Credentials" section and create an OAuth client ID. Select "Desktop app" as the application type.

  4. Download Credentials: Download the credentials file in JSON format. This file contains the required information for authentication.

  5. Update Environment Variables: Open the .env file in your project directory and update the following variables with the values from the downloaded credentials file:

    • CLIENT_ID: Replace with the "Client ID" value.

    • CLIENT_SECRET: Replace with the "Client Secret" value.

    • REDIRECT_URL: Replace with the redirect URL value.

    • DRIVE_FOLDER_ID: Replace with the ID of the Google Drive folder you want to synchronize with.

      • To get the DRIVE_FOLDER_ID for your Google Drive folder, follow these steps:
      1. Navigate to Google Drive.
      2. Locate the desired folder you want to synchronize with.
      3. Right-click on the folder and select "Get link" or "Share".
      4. The folder ID will be present in the URL after the /folders/ or /drive/folders/ part. It will typically be a long string of characters like this 1RI64MLhHqF7XL_8MZOxYLL5d0cMWtLKH.
    • WATCH_PATH: Replace with the local folder path you want to monitor.

How to use

To use the Google Drive Sync Module in your Node.js project, import it and call the syncDirectoryWithGoogleDrive function with the required parameters:

const syncDirectoryWithGoogleDrive = require("google-drive-sync-directory");

const clientId = "YOUR_CLIENT_ID";
const clientSecret = "YOUR_CLIENT_SECRET";
const redirectUri = "http://localhost"; // Set this to the callback URL in your OAuth settings
const folderId = "YOUR_FOLDER_ID";
const watchPath = "./path/to/monitor";

syncDirectoryWithGoogleDrive(clientId, clientSecret, redirectUri, folderId, watchPath)
  .catch((error) => {
    console.error("An error occurred:", error);
  });

Replace YOUR_CLIENT_ID, YOUR_CLIENT_SECRET, YOUR_FOLDER_ID, and WATCH_PATH with your own values.

Authorization

If the application asks for authorization, follow these steps:

  1. Click on the URL displayed in the terminal to grant permissions to the application.

  2. After granting permissions, copy the authorization code from the redirected URL and paste it into the terminal.

  3. The code will be exchanged for an access token, which will be saved to a file for future use.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

The Google Drive Sync Module utilizes the googleapis, readline-promise, and chokidar npm packages for Google Drive API integration, OAuth flow, and file system monitoring, respectively. We acknowledge and appreciate the contributions of the developers of these packages.