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

@b2y/document-module

v1.0.4

Published

A flexible multi-provider storage adapter for file operations across S3, Azure Blob, Google Drive, and local storage

Readme

/**

document-module

A flexible multi-provider storage adapter for file operations across AWS S3, Azure Blob Storage, Google Drive, and local storage.

Features

  • Common interface for multiple storage providers
  • Supports AWS S3, Azure Blob Storage, Local file system, and Google Drive (placeholder)
  • Easily switch between providers without changing your code
  • Support for uploading files from paths, buffers, or streams
  • Generate public/presigned URLs for stored files
  • Configurable via environment variables or direct parameters

Installation

npm install @b2y/document-module

Usage

Basic Usage

const { storageService, STORAGE_TYPES,FILE_PATHS } = require('@b2y/document-module');

// Upload a file using the default provider (set via environment)
const result = await storageService.uploadFile(
  { 
    path: './myfile.jpg',
    originalname: 'myfile.jpg',
    mimetype: 'image/jpeg'
  }, 
  'uploads'
);

console.log('Upload result:', result);

// Get a public URL for the file
const url = await storageService.getPublicUrl(result.path);
console.log('File URL:', url);

// Switch to a different provider
storageService.setStorageProvider(STORAGE_TYPES.LOCAL_DRIVE, {
  basePath: './local-storage',
  baseUrl: 'http://localhost:3000/files'
});


const { StorageFactory, STORAGE_TYPES,FILE_PATHS } = require('@b2y/document-module');

// Create an S3 provider with custom configuration
const s3Provider = StorageFactory.createStorageProvider(STORAGE_TYPES.AMAZON_S3, {
  region: 'us-west-2',
  bucketName: 'my-bucket',
  accessKeyId: 'MY_ACCESS_KEY',
  secretAccessKey: 'MY_SECRET_KEY',
  urlExpiresIn: 3600 // URL expiration in seconds
});

// Create an Azure provider
const azureProvider = StorageFactory.createStorageProvider(STORAGE_TYPES.AZURE_BLOB, {
  connectionString: 'MY_CONNECTION_STRING',
  containerName: 'my-container',
  sasExpiryTime: 3600
});

// Upload using the specific provider
const result = await s3Provider.uploadFile(
  Buffer.from('Hello World'), 
  'text-files/hello.txt'
);


Environment Variables
You can configure the adapter using environment variables:
General

DOCUMENT_STORAGE_TYPE: Default storage type ('AMAZON_S3', 'AZURE_BLOB', 'LOCAL_DRIVE', 'GOOGLE_DRIVE')

AWS S3

AWS_REGION: AWS region
AWS_ACCESS_KEY_ID: AWS access key ID
AWS_SECRET_ACCESS_KEY: AWS secret access key
AWS_S3_BUCKET_NAME: S3 bucket name
AWS_URL_EXPIRES_IN: URL expiration time in seconds (default: 86400)

Azure Blob Storage

AZURE_STORAGE_CONNECTION_STRING: Azure storage connection string
AZURE_STORAGE_ACCOUNT_NAME: Azure storage account name
AZURE_STORAGE_ACCOUNT_KEY: Azure storage account key
AZURE_STORAGE_CONTAINER_NAME: Azure container name (default: 'documents')
AZURE_SAS_EXPIRY_SECONDS: SAS token expiry time in seconds (default: 86400)
AZURE_PUBLIC_ACCESS: Set to 'true' to use public container access

Local Storage

LOCAL_STORAGE_PATH: Base path for local storage (default: './storage')
LOCAL_STORAGE_URL: Base URL for accessing files (e.g., 'http://localhost:3000/files')