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

paywall-consumer-server

v1.0.0

Published

Server for consuming the paywall API

Readme

Consumer Proxy Server

The consumer proxy server is a Node.js Express application that acts as an intermediary between the frontend client and the paywall API service, managing API key authentication and providing a clean interface for content consumption.

Architecture

Core Components

  • Express Proxy Server - Lightweight Node.js server with CORS support
  • API Key Management - Embedded API key handling for paywall service authentication
  • Request Proxying - Transparent request forwarding with authentication injection
  • Stream Processing - Efficient streaming of video and image content
  • Error Handling - Comprehensive error management and client feedback

Features

Proxy Functionality

  • Transparent Proxying - Seamlessly forwards requests to paywall API
  • Authentication Injection - Automatically adds API keys to paywall requests
  • Stream Support - Efficiently streams large video files without memory buffering
  • Error Translation - Converts paywall API errors to client-friendly responses

Content Support

  • HTML Content - Proxy HTML articles and documents
  • Image Streaming - Stream images with proper content headers
  • Video Streaming - Support for segmented video delivery with range requests
  • Content Listing - Proxy content catalog and duration options

Configuration Management

  • Environment Variables - Configurable paywall API endpoint and port
  • API Key Storage - Secure API key management for paywall authentication
  • Request Timeout - Configurable timeout for paywall requests
  • CORS Configuration - Flexible cross-origin request handling

API Endpoints

All endpoints proxy to the corresponding paywall API endpoints:

Content Management

  • GET /api/content/list - List all available content
  • GET /api/content/durations - Get available duration options

Content Delivery

  • GET /api/html/:id - Proxy HTML content from paywall
  • GET /api/image/:id - Stream image content with proper headers
  • GET /api/video/:id - Stream video segments with range support

Video Control

  • DELETE /api/video/:id/progress - Reset video progress

System

  • GET /health - Health check endpoint

Configuration

Environment variables:

  • PORT - Server port (default: 4006)
  • PAYWALL_API_URL - Paywall service endpoint (default: http://localhost:4005)
  • API_KEY - API key for paywall authentication (default: test-key-123)
  • REQUEST_TIMEOUT - Request timeout in milliseconds

Development

# Install dependencies
npm install

# Development server with auto-reload
npm run dev

# Production server
npm start

Architecture Benefits

Security

  • API Key Encapsulation - Frontend never needs to know paywall API keys
  • Request Validation - Server-side validation of requests before proxying
  • Error Sanitization - Prevents sensitive paywall error details from reaching client

Performance

  • Stream Processing - Videos and images streamed without memory buffering
  • Connection Pooling - Efficient HTTP connection reuse to paywall API
  • Request Optimization - Single hop between frontend and proxy

Maintainability

  • Clean Separation - Clear separation between client and paywall concerns
  • Centralized Configuration - Single point for API endpoint and key management
  • Modular Design - Easy to extend with additional proxy functionality

Request Flow

  1. Client Request - Frontend makes request to proxy server
  2. Authentication - Proxy adds API key header for paywall authentication
  3. Forwarding - Request forwarded to paywall service with authentication
  4. Response Processing - Paywall response processed and streamed back to client
  5. Error Handling - Any errors converted to client-appropriate responses

Stream Management

  • Automatic Cleanup - Stream resources automatically cleaned up on client disconnect
  • Memory Efficiency - Large files streamed without loading into memory
  • Range Request Support - HTTP range requests passed through for video seeking
  • Content Headers - Proper content-type and caching headers maintained