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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gdrive-as-storage

v1.0.2

Published

A Node.js library that allows you to use Google Drive as a storage solution, providing an S3-like interface for file operations.

Readme

gdrive-as-storage

Use Google Drive as a Node.js storage backend with an S3-like interface.

npm version

Features

  • S3-style slash paths — write to /images/avatar.jpg and intermediate folders are created automatically
  • Stream-based uploads — accepts any Node.js Readable stream; MIME type inferred from file extension
  • Public file sharing — pass isPublic: true to make a file publicly readable in one step
  • Upload progress — optional onProgress callback receives bytes uploaded during the transfer
  • Automatic retry — exponential backoff on transient Drive API errors (rate limits, 5xx)

Installation

npm install gdrive-as-storage

Requires Node.js 18 or later.

Quick Start

import 'dotenv/config'; // load .env file
import { DriveStorage } from 'gdrive-as-storage';
import { createReadStream } from 'fs';

const storage = new DriveStorage({
  clientId:     process.env.DRIVE_CLIENT_ID!,
  clientSecret: process.env.DRIVE_CLIENT_SECRET!,
  refreshToken: process.env.DRIVE_REFRESH_TOKEN!,
  rootFolderId: process.env.DRIVE_ROOT_FOLDER_ID!,
});

const result = await storage.upload({
  filePath:   '/images/avatar.jpg',
  fileStream: createReadStream('./avatar.jpg'),
});

console.log(result.downloadUrl); // direct download link
console.log(result.viewUrl);     // Google Drive viewer link

Google Cloud Setup

  1. Open Google Cloud Console and create or select a project.
  2. Go to APIs & Services → Library, search for Google Drive API, and enable it.
  3. Go to APIs & Services → Credentials → Create Credentials → OAuth client ID.
    • Application type: Desktop app
    • Note your Client ID and Client Secret.
  4. Run the interactive setup wizard. It will prompt for your Client ID and Client Secret, then open a browser for Google sign-in, capture the OAuth callback, and append credentials to your .env file:
npx gdrive-as-storage
  1. When prompted, paste your Root Folder ID — the alphanumeric string at the end of your Drive folder's URL (https://drive.google.com/drive/folders/<ROOT_FOLDER_ID>).

After the wizard completes, your .env will contain:

DRIVE_CLIENT_ID="..."
DRIVE_CLIENT_SECRET="..."
DRIVE_REFRESH_TOKEN="..."
DRIVE_ROOT_FOLDER_ID="..."

API Reference

new DriveStorage(config)

| Field | Type | Description | |---|---|---| | rootFolderId | string | Drive folder ID used as the storage root | | clientId | string | OAuth 2.0 Client ID from Google Cloud Console | | clientSecret | string | OAuth 2.0 Client Secret | | refreshToken | string | Long-lived refresh token obtained via the init wizard |

upload(params): Promise<UploadResult>

| Field | Type | Required | Description | |---|---|---|---| | filePath | string | ✓ | Slash path relative to root, e.g. /images/avatar.jpg | | fileStream | Readable | ✓ | Node.js Readable stream of the file contents | | mimeType | string | — | MIME type override; inferred from extension if omitted | | isPublic | boolean | — | Make the file publicly readable (default: false) | | onProgress | (bytesUploaded: number) => void | — | Called periodically with bytes read from the source stream |

Returns:

| Field | Type | Description | |---|---|---| | fileId | string | Google Drive file ID | | downloadUrl | string | Direct download link (works without auth for public files) | | viewUrl | string | Google Drive viewer URL |

delete(filePath: string): Promise<void>

Deletes the file at the given slash path. Throws an error if the file is not found.

License

MIT