or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdlegacy-constants.mdreason-phrases.mdstatus-codes.mdutility-functions.md
tile.json

legacy-constants.mddocs/

Legacy Constants

Individual HTTP status code constants provided for backwards compatibility with v1 API. These are deprecated in favor of the StatusCodes enum.

Capabilities

Individual Status Code Constants

Standalone numeric constants for each HTTP status code, maintained for v1 backwards compatibility.

/**
 * @deprecated Please use StatusCodes.ACCEPTED
 */
const ACCEPTED = 202;

/**
 * @deprecated Please use StatusCodes.BAD_GATEWAY
 */
const BAD_GATEWAY = 502;

/**
 * @deprecated Please use StatusCodes.BAD_REQUEST
 */
const BAD_REQUEST = 400;

/**
 * @deprecated Please use StatusCodes.CONFLICT
 */
const CONFLICT = 409;

/**
 * @deprecated Please use StatusCodes.CONTINUE
 */
const CONTINUE = 100;

/**
 * @deprecated Please use StatusCodes.CREATED
 */
const CREATED = 201;

/**
 * @deprecated Please use StatusCodes.EXPECTATION_FAILED
 */
const EXPECTATION_FAILED = 417;

/**
 * @deprecated Please use StatusCodes.FAILED_DEPENDENCY
 */
const FAILED_DEPENDENCY = 424;

/**
 * @deprecated Please use StatusCodes.FORBIDDEN
 */
const FORBIDDEN = 403;

/**
 * @deprecated Please use StatusCodes.GATEWAY_TIMEOUT
 */
const GATEWAY_TIMEOUT = 504;

/**
 * @deprecated Please use StatusCodes.GONE
 */
const GONE = 410;

/**
 * @deprecated Please use StatusCodes.HTTP_VERSION_NOT_SUPPORTED
 */
const HTTP_VERSION_NOT_SUPPORTED = 505;

/**
 * @deprecated Please use StatusCodes.IM_A_TEAPOT
 */
const IM_A_TEAPOT = 418;

/**
 * @deprecated Please use StatusCodes.INSUFFICIENT_SPACE_ON_RESOURCE
 */
const INSUFFICIENT_SPACE_ON_RESOURCE = 419;

/**
 * @deprecated Please use StatusCodes.INSUFFICIENT_STORAGE
 */
const INSUFFICIENT_STORAGE = 507;

/**
 * @deprecated Please use StatusCodes.INTERNAL_SERVER_ERROR
 */
const INTERNAL_SERVER_ERROR = 500;

/**
 * @deprecated Please use StatusCodes.LENGTH_REQUIRED
 */
const LENGTH_REQUIRED = 411;

/**
 * @deprecated Please use StatusCodes.LOCKED
 */
const LOCKED = 423;

/**
 * @deprecated Please use StatusCodes.METHOD_FAILURE
 */
const METHOD_FAILURE = 420;

/**
 * @deprecated Please use StatusCodes.METHOD_NOT_ALLOWED
 */
const METHOD_NOT_ALLOWED = 405;

/**
 * @deprecated Please use StatusCodes.MOVED_PERMANENTLY
 */
const MOVED_PERMANENTLY = 301;

/**
 * @deprecated Please use StatusCodes.MOVED_TEMPORARILY
 */
const MOVED_TEMPORARILY = 302;

/**
 * @deprecated Please use StatusCodes.MULTI_STATUS
 */
const MULTI_STATUS = 207;

/**
 * @deprecated Please use StatusCodes.MULTIPLE_CHOICES
 */
const MULTIPLE_CHOICES = 300;

/**
 * @deprecated Please use StatusCodes.NETWORK_AUTHENTICATION_REQUIRED
 */
const NETWORK_AUTHENTICATION_REQUIRED = 511;

/**
 * @deprecated Please use StatusCodes.NO_CONTENT
 */
const NO_CONTENT = 204;

/**
 * @deprecated Please use StatusCodes.NON_AUTHORITATIVE_INFORMATION
 */
const NON_AUTHORITATIVE_INFORMATION = 203;

/**
 * @deprecated Please use StatusCodes.NOT_ACCEPTABLE
 */
const NOT_ACCEPTABLE = 406;

/**
 * @deprecated Please use StatusCodes.NOT_FOUND
 */
const NOT_FOUND = 404;

/**
 * @deprecated Please use StatusCodes.NOT_IMPLEMENTED
 */
const NOT_IMPLEMENTED = 501;

/**
 * @deprecated Please use StatusCodes.NOT_MODIFIED
 */
const NOT_MODIFIED = 304;

/**
 * @deprecated Please use StatusCodes.OK
 */
const OK = 200;

/**
 * @deprecated Please use StatusCodes.PARTIAL_CONTENT
 */
const PARTIAL_CONTENT = 206;

/**
 * @deprecated Please use StatusCodes.PAYMENT_REQUIRED
 */
const PAYMENT_REQUIRED = 402;

/**
 * @deprecated Please use StatusCodes.PERMANENT_REDIRECT
 */
const PERMANENT_REDIRECT = 308;

/**
 * @deprecated Please use StatusCodes.PRECONDITION_FAILED
 */
const PRECONDITION_FAILED = 412;

/**
 * @deprecated Please use StatusCodes.PRECONDITION_REQUIRED
 */
const PRECONDITION_REQUIRED = 428;

/**
 * @deprecated Please use StatusCodes.PROCESSING
 */
const PROCESSING = 102;

/**
 * @deprecated Please use StatusCodes.PROXY_AUTHENTICATION_REQUIRED
 */
const PROXY_AUTHENTICATION_REQUIRED = 407;

/**
 * @deprecated Please use StatusCodes.REQUEST_HEADER_FIELDS_TOO_LARGE
 */
const REQUEST_HEADER_FIELDS_TOO_LARGE = 431;

/**
 * @deprecated Please use StatusCodes.REQUEST_TIMEOUT
 */
const REQUEST_TIMEOUT = 408;

/**
 * @deprecated Please use StatusCodes.REQUEST_TOO_LONG
 */
const REQUEST_TOO_LONG = 413;

/**
 * @deprecated Please use StatusCodes.REQUEST_URI_TOO_LONG
 */
const REQUEST_URI_TOO_LONG = 414;

/**
 * @deprecated Please use StatusCodes.REQUESTED_RANGE_NOT_SATISFIABLE
 */
const REQUESTED_RANGE_NOT_SATISFIABLE = 416;

/**
 * @deprecated Please use StatusCodes.RESET_CONTENT
 */
const RESET_CONTENT = 205;

/**
 * @deprecated Please use StatusCodes.SEE_OTHER
 */
const SEE_OTHER = 303;

/**
 * @deprecated Please use StatusCodes.SERVICE_UNAVAILABLE
 */
const SERVICE_UNAVAILABLE = 503;

/**
 * @deprecated Please use StatusCodes.SWITCHING_PROTOCOLS
 */
const SWITCHING_PROTOCOLS = 101;

/**
 * @deprecated Please use StatusCodes.TEMPORARY_REDIRECT
 */
const TEMPORARY_REDIRECT = 307;

/**
 * @deprecated Please use StatusCodes.TOO_MANY_REQUESTS
 */
const TOO_MANY_REQUESTS = 429;

/**
 * @deprecated Please use StatusCodes.UNAUTHORIZED
 */
const UNAUTHORIZED = 401;

/**
 * @deprecated Please use StatusCodes.UNPROCESSABLE_ENTITY
 */
const UNPROCESSABLE_ENTITY = 422;

/**
 * @deprecated Please use StatusCodes.UNSUPPORTED_MEDIA_TYPE
 */
const UNSUPPORTED_MEDIA_TYPE = 415;

/**
 * @deprecated Please use StatusCodes.USE_PROXY
 */
const USE_PROXY = 305;

Default Export Object

Combined object containing all legacy constants plus utility functions for v1 compatibility.

/**
 * Default export combining legacy constants and utility functions
 * @deprecated Use named imports with StatusCodes enum instead
 */
const defaultExport: {
  // All legacy constants (54 total)
  ACCEPTED: 202;
  BAD_GATEWAY: 502;
  BAD_REQUEST: 400;
  // ... (remaining 51 constants)
  
  // Utility functions
  getStatusCode: (reasonPhrase: string) => number;
  getStatusText: (statusCode: number | string) => string;
};

Migration Guide

From v1 Individual Constants to v2 StatusCodes Enum

// v1 (deprecated) - individual imports
import { OK, NOT_FOUND, INTERNAL_SERVER_ERROR } from "http-status-codes";

// v2 (recommended) - enum import
import { StatusCodes } from "http-status-codes";

// Usage migration
// Old: OK
// New: StatusCodes.OK

// Old: NOT_FOUND  
// New: StatusCodes.NOT_FOUND

// Old: INTERNAL_SERVER_ERROR
// New: StatusCodes.INTERNAL_SERVER_ERROR

From v1 Default Import to v2 Named Imports

// v1 (deprecated) - default import
import HttpStatus from "http-status-codes";

const status = HttpStatus.OK;
const phrase = HttpStatus.getStatusText(200);

// v2 (recommended) - named imports
import { StatusCodes, getReasonPhrase } from "http-status-codes";

const status = StatusCodes.OK;
const phrase = getReasonPhrase(200);

Usage Examples (Legacy Support)

// These still work but are deprecated
import { 
  OK, 
  NOT_FOUND, 
  INTERNAL_SERVER_ERROR,
  getStatusText // deprecated alias
} from "http-status-codes";

// Legacy usage patterns
app.get("/users/:id", (req, res) => {
  const user = findUser(req.params.id);
  
  if (!user) {
    return res.status(NOT_FOUND).json({
      error: getStatusText(NOT_FOUND)
    });
  }
  
  res.status(OK).json(user);
});

// Default export usage (deprecated)
import HttpStatus from "http-status-codes";

response.status(HttpStatus.OK);
const phrase = HttpStatus.getStatusText(500);

Backwards Compatibility Notes

  • All v1 individual constants maintain exact same numeric values
  • getStatusText()
    function preserved as deprecated alias for
    getReasonPhrase()
  • Default export maintains same structure as v1 but with deprecation warnings
  • No breaking changes - existing v1 code continues to work
  • TypeScript users get deprecation warnings to guide migration