New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

http-status-identifier

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-status-identifier

Get definitions for HTTP status codes

latest
Source
npmnpm
Version
2.0.2
Version published
Maintainers
1
Created
Source

HTTP Status Identifier

Greenkeeper badge Build Status codecov npm version npm

Purpose

A simple Node JS client that returns an HTTP Status, wrapped in a Promise, given either a status code (i.e 200) or the status name (i.e I'm a teapot).

It also returns an HTTP Status Family (INFORMATIONAL or 1xx, SUCCESS or 2xx, REDIRECTION or 3xx, CLIENT ERROR or 4xx, SERVER ERROR or 5xx) given a status family name or a specific HTTP Status.

Installation

Install via NPM.

npm install http-status-identifier

API

HTTP Statuses

To retrieve HTTP statuses use the identifyStatus method.

The identifyStatus method expects either

  • an HTTP status code, represented as a string or a number
  • an HTTP status name, represented as a string

The returned HttpStatus object contains the following fields:

  • name: A string which represents the name for the HTTP status
  • code: A number which represents the code for the HTTP status
  • description: A string that provides a brief overview of the HTTP status
  • supplementaryInformation: A string that provides additional information for the HTTP status. This field may be empty where additional information is not necessary.
  • documentationUrl: A string that represents the URL where official documentation for the HTTP status is found. This is often a URL to RFC documentation.

Example

import { identifyStatus } from 'http-status-identifier';

// Returns HttpStatus.OK
const okHttpStatus = identifyStatus(200);

// Returns HttpStatus.IM_A_TEAPOT
const imATeapotHttpStatus = identifyStatus("I'm a teapot");

// Returns HttpStatus.BAD_REQUEST
const badRequestHttpStatus = identifyStatus('400');

HTTP Status Families

To retrieve the HTTP Family for a given status use the identifyFamily method.

The identifyFamily method expects either

  • an HTTP status code, represented as a string or a number
  • an HTTP status name, represented as a string

Example

import { identifyFamily } from 'http-status-identifier';

// Returns HttpStatusFamily.SUCCESS
const successFamily = identifyFamily('sUcCesS');

// Returns HttpStatusFamily.SUCCESS
const successFamilyAgain = identifyFamily(200);

Keywords

http

FAQs

Package last updated on 12 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts