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 🙏

© 2025 – Pkg Stats / Ryan Hefner

require-from-drive

v4.0.3

Published

Load JSON from Google Drive. This is a way to make sure configuration or secrets are always the same from person to person and server to server.

Readme

This library lets you load JSON-containing Google Docs. Loading is fingerprint-protected on macOS laptops or can be token-protected for servers and other computers.

There are two parts:

  • an Apps Script you'll put in Google Drive
  • A node module to load things from Google drive

Install

As of v4, node >= 24.0.0 is required and macOS with a fingerprint reader is recommended

npm install --save require-from-drive

Use

IMPORTANT: Each time the apps script is changed, you'll need to deploy a new version as a web app. Otherwise, your changes won't end up in the live version.

First, follow these steps to set up Google Drive:

  1. Create a folder on Google Drive. Name it something like "app secrets"
  2. Create an apps script in the folder, and paste the contents of packages/appsScript/server.js in it.
  3. Get the folder ID and put it in the Apps Script's thisFolderId variable
  4. Create a blank, single-column spreadsheet in the folder, and paste its entire URL in the Apps Script's spreadsheetLoggingUrl variable. Logs about requests will be stored in this spreadsheet.
  5. Deploy as a web app, and copy the url.
  6. Set the local REQUIRE_FROM_DRIVE_SERVER_ADDRESS environment variable to the web app url
  7. Run npx require-from-drive generate-secret and follow the prompts to generate a secret. Repeat as necessary to generate separate tokens for each app or server that will request files.
  8. Add sub-directories and Google Docs containing JSON. Paths to Docs are relative to the folder containing the apps script

Then do this!

import { requireFromDrive } from 'require-from-drive'

const config = await requireFromDrive({ path: 'path/to/project/config.json' })

A memory cache and a file cache are enabled by default. The file cache uses file names prefixed with .require-from-drive.

The memory cache can be disabled by setting the cache option to false. The file cache can be disabled by setting the cacheInFile option to false.

IMPORTANT: Because there's a file cache, you should add .require-from-drive* to your .gitignore

Test

To run the Apps Script tests, use the Apps Script IDE to select "test" from the "Run" menu. An error will be thrown and a message will pop up if any test fails.

To run the local tests, run npm test. If you're running them for the first time, many will fail. Follow the instructions printed after you run the test command to get set up for testing.