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

@streetjs/gateway

v1.0.1

Published

StreetJS API Gateway & Edge Framework: strongly-typed, additive reverse proxy with priority/wildcard/regex routing, pluggable load balancing, health-filtered upstreams, circuit breaking, retries/timeouts, rate limiting, auth/authz, request validation, res

Readme

@streetjs/gateway

StreetJS API Gateway & Edge Framework. A strongly-typed, additive reverse proxy that layers over the streetjs core: priority/wildcard/regex routing, pluggable load balancing, health-filtered upstreams, circuit breaking, retries and timeouts, rate limiting, authentication/authorization, request validation, response transformation, API versioning, CORS, compression, structured logging, metrics/observability, a plugin, a CLI, and in-process testing utilities.

It is additive and backwards compatible: it makes zero modifications to the streetjs core public API. Its only runtime dependency is streetjs; the sibling pillar packages (@streetjs/realtime, @streetjs/queue, @streetjs/events, @streetjs/storage) are declared as optional peer dependencies and are never statically imported by the base entry.

  • ESM / NodeNext, strict TypeScript.
  • Deterministic: all time flows through an injectable Clock, all randomness through an injectable rng, and all forwarding through an injectable Forwarder, so a gateway can be driven reproducibly under test.

Install

npm install @streetjs/gateway streetjs

Quick start

import { createGateway } from "@streetjs/gateway";

const gateway = createGateway({
  services: [
    { name: "users-service", targets: [{ id: "u1", url: "http://127.0.0.1:4001" }] },
    { name: "orders-service", targets: [{ id: "o1", url: "http://127.0.0.1:4002" }] },
  ],
  routes: [
    { pattern: "/users", kind: "prefix", service: "users-service" },
    { pattern: "/orders", kind: "prefix", service: "orders-service" },
  ],
  cors: { origins: ["https://app.example.com"], credentials: true },
  compression: { enabled: true, threshold: 1024 },
  defaults: {
    timeoutMs: 5_000,
    retry: { maxAttempts: 2, baseDelayMs: 50 },
    rateLimit: { scope: "ip", limit: 100, windowMs: 60_000 },
  },
});

const res = await gateway.handle({
  method: "GET",
  path: "/users/42",
  url: "/users/42",
  headers: {},
});
console.log(res.status);

gateway.handle(req) runs one request through the full pipeline and resolves a GatewayResponse. Bind it to a node:http server (or any transport) by translating the incoming request into a GatewayRequest and writing the GatewayResponse back — see docs/configuration.md.

Request pipeline

requestId/logging → body-size limit → CORS → versioning → routing → policy merge
→ rate limit → auth → authz → upstream selection (health filter + load balance)
→ circuit breaker → forward (retry + per-attempt timeout) → response transform
(security headers, CORS, compression) → structured log + telemetry

use()-registered middleware wrap the terminal forward handler as an onion: they run in registration order on the way in and reverse order on the way out, and may short-circuit or transform the response.

Reverse proxy & WebSocket upgrades

httpForwarder is the default HTTP(S) forwarder (streaming request body, header forwarding, AbortSignal cancellation). proxyWebSocketUpgrade bridges a client upgrade event to an upstream, establishing a bidirectional byte tunnel.

Testing utilities (@streetjs/gateway/testing)

  • FakeBackend — a real in-process node:http server (loopback, ephemeral port) a gateway can forward to; records every request.
  • GatewayHarness — a real gateway wired to httpForwarder, with backend registration and status-assertion helpers.
  • FakeGateway — a recording Gateway double that returns canned/queued responses without any real forwarding.

Nothing here touches the internet.

CLI

GatewayCommands provides the following @Command-decorated commands. They are registered by your application through the core CliKernel (construct GatewayCommands and register it, optionally passing a Gateway/GatewayConfig for the operational commands) — they are not part of the standalone @streetjs/cli (street) built-in command set. Once registered they are invoked as:

  • make:gateway-route <Name> [--dir <dir>] — scaffold a typed route.
  • make:proxy <Name> [--dir <dir>] — scaffold a proxy/gateway setup.
  • gateway:routes — list configured routes as pattern → service.
  • gateway:health — print upstream health counts + per-target state.

Example

A runnable, fully in-process example (Browser → Gateway → three backends → Realtime/Storage/Queue/Events) lives under src/examples/edge:

npm run example

Documentation

Development

npm run build   # tsc → dist/
npm test        # node --test dist/tests/*.test.js
npm run lint    # tsc --noEmit

License

MIT