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

@vpdn/pb-sharelink

v0.1.7

Published

A lightweight, serverless file upload and sharing service built on Cloudflare Workers

Readme

pb - Simple File Sharing Service

npm version License: MIT

A lightweight, serverless file upload and sharing service built on Cloudflare Workers. Upload files securely and share them with permanent URLs.

pb upload demo

What is pb?

pb is a modern pastebin-like service for files. It provides:

  • Secure uploads with API key authentication
  • Instant sharing with permanent URLs
  • No file size limits (within Cloudflare's limits)
  • Command-line interface for easy integration
  • Serverless architecture - no servers to maintain
  • Global CDN distribution via Cloudflare

How it works

  1. Upload: Send files via CLI, curl, or API with your API key
  2. Store: Files are stored securely in Cloudflare R2 storage
  3. Share: Get a permanent URL that works forever
  4. Access: Anyone with the URL can download the file

Quick Start

Want to run your own pb instance?

Prerequisites

Installation

Automated Setup (Recommended)

If you're using an AI assistant (like Claude, ChatGPT, or Cursor), you can have it automatically set up pb for you:

Just point your AI assistant to this file: INSTALL.md

The installation guide contains step-by-step commands that AI assistants can execute on your behalf, making the setup process completely hands-free.

Manual Setup

If you prefer to set it up yourself:

  1. Clone and setup

    git clone https://github.com/vpdn/pb.git
    cd pb
    npm install
  2. Login to Cloudflare

    npx wrangler login
  3. Create KV namespace

    npx wrangler kv namespace create "FILES"

    Copy the output and update wrangler.toml with your KV namespace ID.

  4. Deploy to Cloudflare

    npm run deploy

That's it! Your pb service is now running on https://pb.YOUR_SUBDOMAIN.workers.dev

Installation

Install the CLI

npm install -g @vpdn/pb-sharelink

The CLI is now available as pb command after installation.

Using pb

API Key Setup

Access to pb is controlled through API keys. Each key can upload, list, and delete its own files.

  1. Generate an API key

    node scripts/generate-api-key.js "My API Key"

    This creates a key like pb_1234567890abcdef

  2. Deploy the key to Cloudflare

    npm run deploy

    This publishes your API key to the Worker's KV store

  3. Configure your shell (Recommended)

    Add to your shell configuration file (~/.bashrc, ~/.bash_profile, or ~/.zshrc):

    export PB_API_KEY="pb_1234567890abcdef"

    Then reload your shell:

    source ~/.bashrc  # or source ~/.zshrc

Upload files

Once you've installed the CLI and configured PB_API_KEY:

# Upload any file
pb myfile.pdf
# Returns: https://pb.YOUR_SUBDOMAIN.workers.dev/f/abc123def456

# Upload from pipe
echo "Hello world" | pb

# Upload with custom name
cat data.json | pb -n "backup.json"

Alternative methods:

# If you haven't set PB_API_KEY
pb myfile.pdf -key pb_1234567890abcdef

# Use curl directly
curl -X POST \
  -H "Authorization: Bearer pb_1234567890abcdef" \
  -F "file=@./myfile.pdf" \
  https://pb.YOUR_SUBDOMAIN.workers.dev/upload

Common Operations

# Upload files (with PB_API_KEY configured)
pb screenshot.png
pb document.pdf
cat config.json | pb
# Upload files in a directory (top level only)
pb ./static-site
# Upload a directory recursively (structure is preserved under a shared prefix)
pb ./static-site --recursive

# List all your files
pb --list

# List files in JSON format
pb --list --json

# Delete a file
pb --delete https://pb.YOUR_SUBDOMAIN.workers.dev/f/abc123def456
# Delete an entire directory (use the shared prefix returned during upload)
pb --delete https://pb.YOUR_SUBDOMAIN.workers.dev/f/abc123def456

# Upload with JSON output
pb myfile.pdf --json

# Upload with expiration (file expires in 24 hours)
pb temp.txt --expiresAfter 24h

# Upload with expiration (file expires in 7 days)
pb document.pdf --expiresAfter 7d

Use -R as shorthand for --recursive when including subdirectories in a folder upload.

File Expiration

Set automatic file expiration with the --expiresAfter flag:

# Expire in minutes
pb temp.txt --expiresAfter 30m

# Expire in hours  
pb cache.json --expiresAfter 2h

# Expire in days
pb backup.zip --expiresAfter 7d

# Expire in weeks
pb archive.tar --expiresAfter 4w

Features:

  • Files are automatically deleted after expiration
  • Expired files return 410 (Gone) status
  • Cleanup runs every 5 minutes via Cloudflare Cron Triggers
  • List command shows remaining time until expiration

JSON Output

All commands support --json flag for programmatic usage:

# Upload with JSON output
pb file.txt --json
# Output: {"url":"https://pb.example.com/f/abc123","fileId":"abc123","size":1234}

# List files as JSON
pb --list --json
# Output: {"files":[{"fileId":"abc123","originalName":"file.txt","size":1234,"contentType":"text/plain","uploadedAt":"2024-01-01T00:00:00Z","url":"https://pb.example.com/f/abc123"}]}

# Delete with JSON output
pb --delete https://pb.example.com/f/abc123 --json
# Output: {"message":"File deleted successfully","fileId":"abc123"}

# Errors are also returned as JSON
pb nonexistent.txt --json
# Output: {"error":"File not found: nonexistent.txt"}

API Reference

See API.md for detailed API documentation.

License

MIT - Feel free to use this for your own file sharing needs!