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

@luna-park/http-errors

v1.0.0

Published

HTTP errors

Readme

@luna-park/http-errors

A lightweight, type-safe library for handling HTTP errors in TypeScript.

Installation

pnpm add @luna-park/http-errors

Usage

Using the httpError proxy

The most ergonomic way to create HTTP errors is using the httpError proxy. It provides autocompletion for all standard HTTP status codes.

import { httpError } from '@luna-park/http-errors';

// Throws an error with status code 404
throw httpError.NotFound('User not found');

// Throws an error with status code 400
throw httpError.BadRequest();

// Throws an error with status code 500
throw httpError.InternalServerError();

Using the HttpError class

You can also use the HttpError class directly if you need more control.

import { HttpError } from '@luna-park/http-errors';

const error = new HttpError('Custom message');
error.statusCode = 403;
error.expose = true;

throw error;

Checking for HTTP Errors

Use the isHttpError helper to check if an error is an instance of HttpError.

import { isHttpError } from '@luna-park/http-errors';

try {
    // ... code that might throw
} catch (error) {
    if (isHttpError(error)) {
        console.log(`HTTP Error ${error.statusCode}: ${error.message}`);
    }
}

Status Codes

The status object contains all supported status codes and their names.

import { status } from '@luna-park/http-errors';

console.log(status.OK.code); // 200
console.log(status.NotFound.name); // "Not Found"

Features

  • Type-safe: Built with TypeScript for excellent IDE support.
  • Ergonomic: Easy-to-use proxy for common status codes.
  • Expose property: Automatically sets expose: true for 4xx errors (client errors) and false for 5xx errors (server errors), which is useful for middleware that decides whether to send error details to the client.
  • Lightweight: Zero dependencies (uses standard Error and Proxy).

License

MIT (c) Luna Park