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

@anay-maheshwari/http-status-helper

v1.0.0

Published

Zero-dependency lightweight utility for HTTP status codes, messages, categories, and validations

Readme

@anay-maheshwari/http-status-helper

A lightweight, zero-dependency utility library for working with HTTP status codes, messages, categories, and validations in Node.js, Express, Fastify, and browser environments.

License: MIT Zero Dependencies


Features

  • Zero dependencies & ultra-lightweight.
  • Complete HTTP status code database conforming to RFC standards.
  • Full lookup & validation suite: getStatus(), getMessage(), getCategory(), isSuccess(), isError(), isValidStatus(), getStatusesByCategory().
  • Named constants via StatusCodes (e.g., StatusCodes.OK, StatusCodes.NOT_FOUND).
  • ESM & CommonJS compatible with native TypeScript definitions included.
  • Safe edge-case handling: returns null for unknown codes and false for invalid inputs.

Installation

npm install @anay-maheshwari/http-status-helper

Quick Start

import {
  getStatus,
  getMessage,
  getCategory,
  isSuccess,
  isError,
  isValidStatus,
  getStatusesByCategory,
  StatusCodes
} from "@anay-maheshwari/http-status-helper";

// 1. Get complete status information
getStatus(404);
// {
//   code: 404,
//   message: "Not Found",
//   category: "Client Error",
//   type: "error"
// }

// 2. Get status message
getMessage(200); // "OK"
getMessage(500); // "Internal Server Error"
getMessage(999); // null

// 3. Get category name
getCategory(201); // "Success"
getCategory(301); // "Redirection"
getCategory(403); // "Client Error"
getCategory(502); // "Server Error"

// 4. Validate success / error
isSuccess(200); // true
isSuccess(404); // false

isError(400); // true
isError(500); // true
isError(200); // false

// 5. Validate status range
isValidStatus(200);   // true
isValidStatus(999);   // false
isValidStatus("200"); // false

// 6. Filter by category (case-insensitive)
getStatusesByCategory("Client Error");
// [
//   { code: 400, message: "Bad Request" },
//   { code: 401, message: "Unauthorized" },
//   { code: 403, message: "Forbidden" },
//   { code: 404, message: "Not Found" },
//   ...
// ]

// 7. Use named status code constants
StatusCodes.OK;                    // 200
StatusCodes.CREATED;               // 201
StatusCodes.BAD_REQUEST;           // 400
StatusCodes.NOT_FOUND;             // 404
StatusCodes.INTERNAL_SERVER_ERROR; // 500

Usage in Express.js

import express from "express";
import { StatusCodes, getMessage, isSuccess } from "@anay-maheshwari/http-status-helper";

const app = express();

app.get("/api/users", (req, res) => {
  const users = [{ id: 1, name: "Alice" }];

  res.status(StatusCodes.OK).json({
    success: isSuccess(StatusCodes.OK),
    message: getMessage(StatusCodes.OK),
    data: users
  });
});

app.get("/api/users/:id", (req, res) => {
  res.status(StatusCodes.NOT_FOUND).json({
    success: false,
    message: getMessage(StatusCodes.NOT_FOUND)
  });
});

app.listen(3000, () => {
  console.log("Server running on port 3000");
});

API Reference

| Function / Export | Parameters | Returns | Description | | :--- | :--- | :--- | :--- | | getStatus(code) | number | object \| null | Returns { code, message, category, type } or null. | | getMessage(code) | number | string \| null | Returns status text description or null. | | getCategory(code) | number | string \| null | Returns category name or null. | | isSuccess(code) | number | boolean | Returns true if code is in the 200–299 range. | | isError(code) | number | boolean | Returns true if code is in the 400–599 range. | | isValidStatus(code) | any | boolean | Returns true if integer is between 100 and 599. | | getStatusesByCategory(category) | string | Array<{ code, message }> | Returns all codes under the given category. | | StatusCodes | Constant object | Record<string, number> | Predefined immutable status constants. |


HTTP Status Categories

| Range | Category | Type returned by getStatus | | :--- | :--- | :--- | | 100–199 | Informational | "info" | | 200–299 | Success | "success" | | 300–399 | Redirection | "redirection" | | 400–499 | Client Error | "error" | | 500–599 | Server Error | "error" |


Running Tests

This package uses Node.js built-in test runner with zero extra testing dependencies:

npm test

License

MIT