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

@blue.ts/http

v0.2.0

Published

A **PSR-7 inspired** HTTP message implementation for the modern TypeScript ecosystem. Immutable, type-safe, and runtime-agnostic — works on Bun, Deno, and Node.js 20+.

Readme

@blue.ts/http

A PSR-7 inspired HTTP message implementation for the modern TypeScript ecosystem. Immutable, type-safe, and runtime-agnostic — works on Bun, Deno, and Node.js 20+.


Installation

npm install @blue.ts/http

Overview

The package provides three core classes and a file upload abstraction:

| Class | Role | |---|---| | ServerRequest | Incoming request received by your server | | HttpRequest | Outgoing request your code sends to an external service | | HttpResponse | HTTP response, sent back to a client | | UploadedFile | File received via multipart/form-data |

All classes are immutable. Methods prefixed with with return a new instance rather than mutating in place.


ServerRequest

Wraps an incoming Fetch Request into a persistent, fully-parsed snapshot.

import { ServerRequest } from '@blue.ts/http';

const request = await ServerRequest.fromRequest(nativeRequest);

// Parsed body (JSON, multipart, URL-encoded — detected automatically)
const body = request.getParsedBody<{ name: string }>();

// URL & query
const url    = request.getUrl();
const params = request.getQueryParams(); // { page: '2' }

// Headers (case-insensitive)
const auth = request.getHeaderLine('authorization');

// Cookies
const session = request.getCookieParams()['session_id'];

// Uploaded files (multipart)
const files = request.getUploadedFiles(); // Record<string, UploadedFile>

// Attach typed metadata — ideal for middleware
const authed = request.withAttribute('user', { id: 42 });
const user   = authed.getAttribute<{ id: number }>('user');

Immutable withers:

request
  .withMethod('POST')
  .withHeader('x-request-id', crypto.randomUUID())
  .withParsedBody({ validated: true });

HttpRequest

Builder for outgoing HTTP calls. Executes via send(), which returns an HttpResponse.

import { HttpRequest } from '@blue.ts/http';

// Static factories
const listRes = await HttpRequest.get('https://api.example.com/users')
    .withQueryParam('page', '2')
    .withBearerToken(token)
    .send();

// POST with JSON body
const createRes = await HttpRequest.post('https://api.example.com/users')
    .withJson({ name: 'Alice', role: 'admin' })
    .send();

// Basic auth
const dataRes = await HttpRequest.get('https://api.example.com/data')
    .withBasicAuth('user', 'p@ssw0rd')
    .send();

Static factories: HttpRequest.get(), .post(), .put(), .patch(), .delete(), .create(method, url)


HttpResponse

Immutable response builder. Convert to a native Response via toStandard() when returning from your handler.

import { HttpResponse } from '@blue.ts/http';

// JSON response
const okRes = new HttpResponse(200)
    .withJson({ id: 1, name: 'Alice' });

// Custom status and headers
const createdRes = new HttpResponse(201)
    .withHeader('x-request-id', requestId)
    .withJson({ created: true });

// Redirect
const redirectRes = new HttpResponse(302)
    .withHeader('location', '/login');

// Return to adapter
return okRes.toStandard();

Convert from a native Response (e.g., from fetch):

const fetchedRes = HttpResponse.fromStandard(await fetch(url));
const status = fetchedRes.getStatusCode(); // 200

UploadedFile

Files from multipart/form-data requests are available via ServerRequest.getUploadedFiles(). Files larger than 256 KB are automatically spooled to disk; smaller files are kept in memory.

const files = request.getUploadedFiles();
const avatar = files['avatar'];

avatar.name;      // original filename
avatar.mediaType; // MIME type
avatar.size;      // bytes
avatar.error;     // UploadError.OK if successful

// Stream the file
const stream = avatar.getStream();

// Move to permanent storage
await avatar.moveTo('/uploads/avatar.png');

Interfaces

All public interfaces are re-exported for use in your own implementations or middleware:

import type {
    MessageInterface,
    RequestInterface,
    ResponseInterface,
    ServerRequestInterface,
    ServerParams,
} from '@blue.ts/http';

Runtime Compatibility

| Runtime | Minimum Version | |---|---| | Bun | 1.0+ | | Deno | 1.28+ | | Node.js | 20+ |

File as a global requires Node.js 20+. Node 18 users must polyfill it.


License

MIT