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

@relayer-ws/plain-proxy-sdk

v1.0.0

Published

Cloudflare Worker SDK for Plain Proxy

Readme

Plain Proxy SDK

A TypeScript SDK for making HTTP requests through Plain proxy-enabled Lambda functions from Cloudflare Workers.

Note: All requests made through this SDK will appear to come from the IP address 3.38.55.163. This is useful for scenarios where you need a consistent outbound IP address for your requests.

Features

  • 🚀 Easy to use - Simple API similar to native fetch
  • 🔧 TypeScript support - Full type definitions included
  • Cloudflare Workers ready - Optimized for Cloudflare Workers environment
  • 🛡️ Timeout handling - Built-in request timeout support
  • 📦 Multiple interfaces - Both class-based and functional APIs
  • 🔄 All HTTP methods - GET, POST, PUT, DELETE, PATCH, HEAD support
  • 🌐 Fixed IP address - All requests are sent from IP address 3.38.55.163

Installation

npm install @relayer-ws/plain-proxy-sdk

Quick Start

Using the PlainProxyClient class

import { PlainProxyClient } from "@relayer-ws/plain-proxy-sdk";

// Create a client with default settings
const proxy = new PlainProxyClient({});

// Make a proxied request
const response = await proxy.get("https://api.example.com/data", {
  Authorization: "Bearer your-token",
});

const data = await response.json();
console.log(data);

Using the fetch-like API

import { createPlainFetch } from "@relayer-ws/plain-proxy-sdk";

// Create a fetch-like function
const PlainFetch = createPlainFetch({
  proxyUrl: "https://gw.relayer.ws/plain",
});

// Use it just like the native fetch API
const response = await PlainFetch("https://api.example.com/data", {
  method: "POST",
  headers: {
    Authorization: "Bearer token",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ data: "value" }),
});

const result = await response.json();

Configuration

PlainProxyConfig

interface PlainProxyConfig {
  /** The URL of the Plain proxy Lambda function (default: https://gw.relayer.ws/plain) */
  proxyUrl?: string;
  /** Optional timeout for requests (default: 30000ms) */
  timeout?: number;
}

Example with custom configuration

const proxy = new PlainProxyClient({
  proxyUrl: "https://your-custom-proxy.amazonaws.com",
  timeout: 60000, // 60 seconds
});

API Reference

PlainProxyClient

The main client class for making proxied requests.

Constructor

new PlainProxyClient(config: PlainProxyConfig)

Methods

request(options: ProxyRequestOptions): Promise<Response>

Make a proxied request with full control over the request parameters.

const response = await proxy.request({
  targetUrl: "https://api.example.com",
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ key: "value" }),
  timeout: 10000,
});
HTTP Method Helpers

Convenience methods for common HTTP methods:

// GET request
await proxy.get("https://api.example.com/data", headers);

// POST request
await proxy.post("https://api.example.com/data", body, headers);

// PUT request
await proxy.put("https://api.example.com/data", body, headers);

// DELETE request
await proxy.delete("https://api.example.com/data", headers);

// PATCH request
await proxy.patch("https://api.example.com/data", body, headers);

// HEAD request
await proxy.head("https://api.example.com/data", headers);

createPlainFetch

Create a fetch-like function that works like the native fetch API.

const PlainFetch = createPlainFetch(config);
const response = await PlainFetch(url, init);

createPlainProxyClient

Factory function to create a new PlainProxyClient instance.

const client = createPlainProxyClient(config);

Types

ProxyRequestOptions

interface ProxyRequestOptions {
  /** Target URL to proxy to */
  targetUrl: string;
  /** HTTP method */
  method?: string;
  /** Request headers */
  headers?: Record<string, string | undefined>;
  /** Request body */
  body?: string | ArrayBuffer | ReadableStream;
  /** Request timeout (overrides config timeout) */
  timeout?: number;
}

ProxyResponse

interface ProxyResponse {
  /** HTTP status code */
  status: number;
  /** HTTP status text */
  statusText: string;
  /** Response headers */
  headers: Record<string, string>;
  /** Response body */
  body: string;
  /** Whether the response body is base64 encoded */
  isBase64Encoded: boolean;
}

Examples

Basic GET request

import { PlainProxyClient } from "@relayer-ws/plain-proxy-sdk";

const proxy = new PlainProxyClient({});

try {
  const response = await proxy.get("https://jsonip.com");
  const data = await response.json();
  console.log("Your IP:", data.ip); // Will always show: 3.38.55.163
} catch (error) {
  console.error("Request failed:", error);
}

Verify IP address

import { PlainProxyClient } from "@relayer-ws/plain-proxy-sdk";

const proxy = new PlainProxyClient({});

// Check what IP address your requests appear to come from
const response = await proxy.get("https://httpbin.org/ip");
const data = await response.json();
console.log("Outbound IP:", data.origin); // Will show: 3.38.55.163

POST request with JSON data

const response = await proxy.post(
  "https://api.example.com/users",
  JSON.stringify({ name: "John Doe", email: "[email protected]" }),
  { "Content-Type": "application/json" }
);

if (response.ok) {
  const user = await response.json();
  console.log("Created user:", user);
}

Using with custom timeout

const proxy = new PlainProxyClient({
  timeout: 5000, // 5 seconds
});

// Or override timeout for specific request
const response = await proxy.request({
  targetUrl: "https://slow-api.example.com",
  timeout: 10000, // 10 seconds for this request
});

Error handling

try {
  const response = await proxy.get("https://api.example.com");

  if (!response.ok) {
    throw new Error(`HTTP ${response.status}: ${response.statusText}`);
  }

  const data = await response.json();
  console.log(data);
} catch (error) {
  if (error.message.includes("timeout")) {
    console.error("Request timed out");
  } else {
    console.error("Request failed:", error.message);
  }
}

Development

Building

npm run build

Running tests

npm test

Development mode

npm run dev

License

MIT

Author

relayer.ws