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

@bernierllc/user-storage-service

v0.4.0

Published

Orchestration service for routing file uploads to user-owned or application-owned storage backends

Readme

@bernierllc/user-storage-service

Orchestration service for routing file uploads to user-owned or application-owned storage backends with OAuth token management and billing tracking.

Features

  • Multi-storage routing - Route files to Dropbox, Google Drive, or S3
  • OAuth token management - Automatic token refresh for user-owned storage
  • Billing integration - Track S3 usage for billing purposes
  • Storage connection status - Check if users have connected storage providers
  • Usage tracking - Monitor storage usage for billing

Installation

npm install @bernierllc/user-storage-service

Usage

Basic Setup

import { UserStorageService } from '@bernierllc/user-storage-service';

// Token storage implementation
const tokenStorage: TokenStorage = {
  async store(userId, provider, tokens) {
    await db.saveTokens(userId, provider, tokens);
  },
  async retrieve(userId, provider) {
    return await db.getTokens(userId, provider);
  },
  async delete(userId, provider) {
    await db.deleteTokens(userId, provider);
  }
};

// Billing service implementation (optional)
const billingService: BillingService = {
  async recordUsage(usage) {
    await db.recordStorageUsage(usage);
  },
  async getUsage(userId, period) {
    return await db.getStorageUsage(userId, period);
  }
};

// Create service instance
const storageService = new UserStorageService({
  userId: currentUser.id,
  tokenStorage,
  billingService
});

Upload Files

// Upload to user's Dropbox
const results = await storageService.uploadFiles(files, {
  storageType: 'dropbox',
  path: 'documents/2024',
  public: false
});

// Upload to user's Google Drive
const results = await storageService.uploadFiles(files, {
  storageType: 'google-drive',
  path: 'uploads',
  public: true
});

// Upload to application's S3 (billed)
const results = await storageService.uploadFiles(files, {
  storageType: 's3',
  path: 'user-uploads',
  public: true
});

Check Storage Connection

// Check if user has connected Dropbox
const hasDropbox = await storageService.isStorageConnected('dropbox');

// Check if user has connected Google Drive
const hasGoogleDrive = await storageService.isStorageConnected('google-drive');

// S3 is always available (application-owned)
const hasS3 = await storageService.isStorageConnected('s3'); // Always true

Get Storage Usage

// Get S3 usage for billing
const usage = await storageService.getStorageUsage('s3');
console.log(`Total bytes: ${usage.totalBytes}`);
console.log(`File count: ${usage.fileCount}`);

API

UserStorageService

Constructor

constructor(config: UserStorageServiceConfig)

Methods

uploadFiles(files: FileData[], options: UserStorageUploadOptions): Promise<UploadResult[]>

Upload files to selected storage backend.

getUserTokens(provider: 'dropbox' | 'google-drive'): Promise<OAuthTokens | null>

Get user's OAuth tokens for a storage provider.

isStorageConnected(provider: StorageType): Promise<boolean>

Check if user has connected a storage provider.

getStorageUsage(provider: 's3'): Promise<StorageUsage>

Get storage usage for user (S3 only, requires billing service).

Environment Variables

For OAuth token refresh:

DROPBOX_CLIENT_ID=your_dropbox_client_id
DROPBOX_CLIENT_SECRET=your_dropbox_client_secret
DROPBOX_REDIRECT_URI=https://yourapp.com/oauth/dropbox/callback

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REDIRECT_URI=https://yourapp.com/oauth/google-drive/callback

For S3 (application-owned storage):

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
AWS_S3_BUCKET=your-bucket-name

License

Copyright (c) 2025 Bernier LLC. See LICENSE file for details.