CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-http-status

Utility to interact with HTTP status codes

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

specialty-modules.mddocs/

Specialty Modules

Pre-configured modules that merge standard HTTP status codes with specific server status codes for convenience, providing a single import for server-specific needs.

Capabilities

Specialty Module Imports

Each specialty module provides all standard HTTP status codes merged with server-specific codes for convenient access.

/**
 * Import specialty modules that merge standard codes with server-specific codes
 * Note: Import paths may vary based on build configuration - check package documentation
 */
// Cloudflare module
import status from "http-status/cloudflare";
import { status } from "http-status/cloudflare";
// Alternative path (check package exports):
// import status from "http-status/lib/cloudflare";

// NGINX module  
import status from "http-status/nginx";
import { status } from "http-status/nginx";
// Alternative path (check package exports):
// import status from "http-status/lib/nginx";

// IIS module
import status from "http-status/iis";
import { status } from "http-status/iis";
// Alternative path (check package exports):
// import status from "http-status/lib/iis";

// Unofficial module
import status from "http-status/unofficial";
import { status } from "http-status/unofficial";
// Alternative path (check package exports):
// import status from "http-status/lib/unofficial";

Usage Examples:

// Using Cloudflare module
import status from "http-status/cloudflare";

// Access standard codes
console.log(status.OK); // 200
console.log(status.NOT_FOUND); // 404

// Access Cloudflare-specific codes directly (no .extra.cloudflare needed)
console.log(status.UNKNOWN_ERROR); // 520
console.log(status.WEB_SERVER_IS_DOWN); // 521
console.log(status[520]); // "Unknown Error"

// Using NGINX module
import status from "http-status/nginx";

// Standard codes work normally
console.log(status.INTERNAL_SERVER_ERROR); // 500

// NGINX codes available directly
console.log(status.NO_RESPONSE); // 444
console.log(status.SSL_CERTIFICATE_ERROR); // 495

Cloudflare Module

Merges standard HTTP status codes with Cloudflare-specific status codes.

/**
 * Cloudflare specialty module - standard codes + Cloudflare codes
 * Import: import status from "http-status/cloudflare";
 */
interface CloudflareModule extends StandardStatusCodes {
  // Cloudflare-specific codes merged at top level
  520: "Unknown Error";
  UNKNOWN_ERROR: 520;
  "520_NAME": "UNKNOWN_ERROR";
  "520_MESSAGE": "The 520 error is used as a \"catch-all response for when the origin server returns something unexpected\".";
  "520_CLASS": "5xx";

  521: "Web Server Is Down";
  WEB_SERVER_IS_DOWN: 521;
  "521_NAME": "WEB_SERVER_IS_DOWN";
  "521_MESSAGE": "The origin server has refused the connection from Cloudflare.";
  "521_CLASS": "5xx";

  522: "Connection Timed Out";
  CONNECTION_TIMED_OUT: 522;
  "522_NAME": "CONNECTION_TIMED_OUT";
  "522_MESSAGE": "Cloudflare could not negotiate a TCP handshake with the origin server.";
  "522_CLASS": "5xx";

  523: "Origin Is Unreachable";
  ORIGIN_IS_UNREACHABLE: 523;
  "523_NAME": "ORIGIN_IS_UNREACHABLE";
  "523_MESSAGE": "Cloudflare could not reach the origin server.";
  "523_CLASS": "5xx";

  524: "A Timeout Occurred";
  A_TIMEOUT_OCCURRED: 524;
  "524_NAME": "A_TIMEOUT_OCCURRED";
  "524_MESSAGE": "Cloudflare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.";
  "524_CLASS": "5xx";

  525: "SSL Handshake Failed";
  SSL_HANDSHAKE_FAILED: 525;
  "525_NAME": "SSL_HANDSHAKE_FAILED";
  "525_MESSAGE": "Cloudflare could not negotiate a SSL/TLS handshake with the origin server.";
  "525_CLASS": "5xx";

  526: "Invalid SSL Certificate";
  INVALID_SSL_CERTIFICATE: 526;
  "526_NAME": "INVALID_SSL_CERTIFICATE";
  "526_MESSAGE": "Cloudflare could not validate the SSL/TLS certificate that the origin server presented.";
  "526_CLASS": "5xx";

  527: "Railgun Error";
  RAILGUN_ERROR: 527;
  "527_NAME": "RAILGUN_ERROR";
  "527_MESSAGE": "Error 527 indicates that the request timed out or failed after the WAN connection had been established.";
  "527_CLASS": "5xx";
}

NGINX Module

Merges standard HTTP status codes with NGINX-specific status codes.

/**
 * NGINX specialty module - standard codes + NGINX codes
 * Import: import status from "http-status/nginx";
 */
interface NGINXModule extends StandardStatusCodes {
  // NGINX-specific codes merged at top level
  444: "No Response";
  NO_RESPONSE: 444;
  "444_NAME": "NO_RESPONSE";
  "444_MESSAGE": "Used internally to instruct the server to return no information to the client and close the connection immediately.";
  "444_CLASS": "4xx";

  494: "Request header too large";
  REQUEST_HEADER_TOO_LARGE: 494;
  "494_NAME": "REQUEST_HEADER_TOO_LARGE";
  "494_MESSAGE": "Client sent too large request or too long header line.";
  "494_CLASS": "4xx";

  495: "SSL Certificate Error";
  SSL_CERTIFICATE_ERROR: 495;
  "495_NAME": "SSL_CERTIFICATE_ERROR";
  "495_MESSAGE": "An expansion of the 400 Bad Request response code, used when the client has provided an invalid client certificate.";
  "495_CLASS": "4xx";

  496: "SSL Certificate Required";
  SSL_CERTIFICATE_REQUIRED: 496;
  "496_NAME": "SSL_CERTIFICATE_REQUIRED";
  "496_MESSAGE": "An expansion of the 400 Bad Request response code, used when a client certificate is required but not provided.";
  "496_CLASS": "4xx";

  497: "HTTP Request Sent to HTTPS Port";
  HTTP_REQUEST_SENT_TO_HTTPS_PORT: 497;
  "497_NAME": "HTTP_REQUEST_SENT_TO_HTTPS_PORT";
  "497_MESSAGE": "An expansion of the 400 Bad Request response code, used when the client has made a HTTP request to a port listening for HTTPS requests.";
  "497_CLASS": "4xx";

  499: "Client Closed Request";
  CLIENT_CLOSED_REQUEST: 499;
  "499_NAME": "CLIENT_CLOSED_REQUEST";
  "499_MESSAGE": "Used when the client has closed the request before the server could send a response.";
  "499_CLASS": "4xx";
}

IIS Module

Merges standard HTTP status codes with IIS-specific status codes.

/**
 * IIS specialty module - standard codes + IIS codes
 * Import: import status from "http-status/iis";
 */
interface IISModule extends StandardStatusCodes {
  // IIS-specific codes merged at top level
  440: "Login Time-out";
  LOGIN_TIME_OUT: 440;
  "440_NAME": "LOGIN_TIME_OUT";
  "440_MESSAGE": "The client's session has expired and must log in again.";
  "440_CLASS": "4xx";

  449: "Retry With";
  RETRY_WITH: 449;
  "449_NAME": "RETRY_WITH";
  "449_MESSAGE": "The server cannot honour the request because the user has not provided the required information.";
  "449_CLASS": "4xx";

  451: "Redirect";
  REDIRECT: 451;
  "451_NAME": "REDIRECT";
  "451_MESSAGE": "Used in Exchange ActiveSync when either a more efficient server is available or the server cannot access the users' mailbox.";
  "451_CLASS": "4xx";
}

Unofficial Module

Merges standard HTTP status codes with unofficial status codes.

/**
 * Unofficial specialty module - standard codes + unofficial codes
 * Import: import status from "http-status/unofficial";
 */
interface UnofficialModule extends StandardStatusCodes {
  // Unofficial codes merged at top level
  103: "Checkpoint";
  CHECKPOINT: 103;
  "103_NAME": "CHECKPOINT";
  "103_MESSAGE": "Used in the resumable requests proposal to resume aborted PUT or POST requests.";
  "103_CLASS": "1xx";

  218: "This is fine";
  THIS_IS_FINE: 218;
  "218_NAME": "THIS_IS_FINE";
  "218_MESSAGE": "Used as a catch-all error condition for allowing response bodies to flow through Apache when ProxyErrorOverride is enabled.";
  "218_CLASS": "2xx";

  419: "Page Expired";
  PAGE_EXPIRED: 419;
  "419_NAME": "PAGE_EXPIRED";
  "419_MESSAGE": "Used by the Laravel Framework when a CSRF Token is missing or expired.";
  "419_CLASS": "4xx";

  420: "Enhance Your Calm";
  ENHANCE_YOUR_CALM: 420;
  "420_NAME": "ENHANCE_YOUR_CALM";
  "420_MESSAGE": "Returned by version 1 of the Twitter Search and Trends API when the client is being rate limited.";
  "420_CLASS": "4xx";

  450: "Blocked by Windows Parental Controls";
  BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS: 450;
  "450_NAME": "BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS";
  "450_MESSAGE": "The Microsoft extension code indicated when Windows Parental Controls are turned on and are blocking access to the requested webpage.";
  "450_CLASS": "4xx";

  // Additional unofficial codes...
}

Integration Examples:

// Express.js with Cloudflare module
import express from "express";
import status from "http-status/cloudflare";

const app = express();

app.get("/api/data", async (req, res) => {
  try {
    const data = await fetchFromOrigin();
    res.status(status.OK).json(data);
  } catch (error) {
    if (error.code === "ORIGIN_DOWN") {
      res.status(status.WEB_SERVER_IS_DOWN).json({
        error: "Origin server is down",
        statusText: status[status.WEB_SERVER_IS_DOWN]
      });
    } else {
      res.status(status.UNKNOWN_ERROR).json({
        error: "Unknown error occurred",
        statusText: status[status.UNKNOWN_ERROR]
      });
    }
  }
});

// NGINX error handling
import status from "http-status/nginx";

function handleNginxError(errorCode: number) {
  switch (errorCode) {
    case status.NO_RESPONSE:
      return {
        message: "No response from server",
        retry: false
      };
    case status.SSL_CERTIFICATE_ERROR:
      return {
        message: "SSL certificate validation failed",
        retry: false
      };
    case status.CLIENT_CLOSED_REQUEST:
      return {
        message: "Client closed connection",
        retry: true
      };
    default:
      return {
        message: "Unknown error",
        retry: false
      };
  }
}

docs

extra-codes.md

index.md

specialty-modules.md

standard-codes.md

status-classes.md

tile.json