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

edgewiz

v1.1.1

Published

Lightweight multi-runtime middleware for rate limiting, request coalescing, and CORS.

Readme

EdgeWiz

A lightweight middleware library for building web servers across multiple JavaScript runtimes.

Write middleware once and run it on:

  • Node.js
  • Bun
  • Deno
  • Cloudflare Workers
  • AWS Lambda

Installation

npm install edgewiz

Features

  • 🌍 Cross-runtime middleware
  • 🚀 Rate limiting
  • 🔒 CORS
  • ⚡ Request coalescing
  • 🔧 Middleware composition
  • 📝 TypeScript support
  • 📦 ESM & CommonJS

Quick Start

Node.js (Express)

import express from "express";
import { toNodeMiddleware, rateLimit } from "edgewiz";

const app = express();

app.use(
  toNodeMiddleware(
    rateLimit({
      limit: 100,
      windowMs: 15 * 60 * 1000,
    })
  )
);

app.get("/", (_, res) => {
  res.json({ message: "Hello World" });
});

app.listen(3000);

Bun / Deno / Cloudflare Workers

import { cors, toFetchHandler } from "edgewiz";

const middleware = cors({
  origin: "*",
});

const handler = toFetchHandler(
  middleware,
  async () => new Response("Hello World")
);

export default {
  fetch: handler,
};

AWS Lambda

import { rateLimit, toLambdaHandler } from "edgewiz";

export const handler = toLambdaHandler(
  rateLimit({
    limit: 50,
    windowMs: 60 * 1000,
  }),
  async () => ({
    statusCode: 200,
    headers: {
      "content-type": "application/json",
    },
    body: JSON.stringify({
      message: "OK",
    }),
  })
);

Middleware

Rate Limiting

import { rateLimit } from "edgewiz";

const middleware = rateLimit({
  limit: 100,
  windowMs: 15 * 60 * 1000,
});

Options

| Option | Description | |---------|-------------| | limit | Maximum requests per window | | max | Alias for limit (Express compatibility) | | windowMs | Time window in milliseconds | | keyGenerator | Generate a custom rate-limit key | | store | Custom storage implementation | | standardHeaders | Adds RateLimit-* headers | | legacyHeaders | Adds X-RateLimit-* headers |


Built-in Key Generators

import {
  rateLimit,
  ipKeyGenerator,
  userIdKeyGenerator,
  ipPathKeyGenerator,
  apiKeyGenerator,
} from "edgewiz";

const middleware = rateLimit({
  limit: 100,
  windowMs: 60 * 1000,
  keyGenerator: ipKeyGenerator,
});

Available generators:

  • ipKeyGenerator
  • userIdKeyGenerator
  • ipPathKeyGenerator
  • apiKeyGenerator

CORS

import { cors } from "edgewiz";

const middleware = cors({
  origin: "*",
  methods: ["GET", "POST"],
  allowedHeaders: [
    "content-type",
    "authorization",
  ],
  credentials: true,
  maxAge: 86400,
});

Origin Examples

Allow all origins

cors({
  origin: "*",
});

Allow a single origin

cors({
  origin: "https://example.com",
});

Allow multiple origins

cors({
  origin: [
    "https://example.com",
    "https://app.example.com",
  ],
});

Custom validation

cors({
  origin(origin) {
    return origin?.endsWith(".example.com");
  },
});

Request Coalescing

import { coalesce } from "edgewiz";

const middleware = coalesce({
  keyGenerator: (req) => `${req.method}:${req.url}`,
});

Multiple identical concurrent requests are processed only once. Remaining requests receive the same response.


Composing Middleware

import {
  compose,
  rateLimit,
  cors,
  coalesce,
} from "edgewiz";

const middleware = compose(
  rateLimit({
    limit: 100,
    windowMs: 60 * 1000,
  }),
  cors({
    origin: "*",
  }),
  coalesce()
);

Middleware executes from top to bottom.


Custom Middleware

import type {
  CoreMiddleware,
} from "edgewiz";

const logger: CoreMiddleware = async (
  req,
  next
) => {
  console.log(req.method, req.url);

  const response = await next();

  response.headers["x-powered-by"] = "EdgeWiz";

  return response;
};

Adapters

Node.js

import { toNodeMiddleware } from "edgewiz/adapters/node";

Extracts

  • IP
  • Method
  • URL
  • Headers

Fetch API

import { toFetchHandler } from "edgewiz/adapters/fetch";

Supports

  • Bun
  • Deno
  • Cloudflare Workers

AWS Lambda

import { toLambdaHandler } from "edgewiz/adapters/lambda";

Extracts

  • IP
  • Method
  • Path
  • Headers

Types

NormalizedRequest

interface NormalizedRequest {
  method: string;
  url: string;
  headers: Record<
    string,
    string | string[]
  >;
  ip?: string;
  body?: string;
}

NormalizedResponse

interface NormalizedResponse {
  status: number;
  headers: Record<
    string,
    string | string[]
  >;
  body?: string | null;
}

CoreMiddleware

type CoreMiddleware = (
  req: NormalizedRequest,
  next: () => Promise<NormalizedResponse>
) => Promise<NormalizedResponse>;

Utilities

import {
  getHeader,
  setHeader,
} from "edgewiz";

const contentType = getHeader(
  req.headers,
  "content-type"
);

setHeader(
  res.headers,
  "cache-control",
  "no-cache"
);

Project Structure

src/
├── index.ts
├── types.ts
├── adapters/
│   ├── node.ts
│   ├── fetch.ts
│   └── lambda.ts
├── rate-limit/
├── cors/
└── coalesce/

test/
dist/

Development

Build

npm run build

Test

npm run test

Watch

npm run dev

Notes

  • Use a distributed store (Redis, etc.) for production rate limiting.
  • Request coalescing only deduplicates concurrent requests.
  • When using CORS with credentials: true, do not use origin: "*".
  • Lambda in-memory state is container-specific.

License

MIT