Skip to content

arnaud-zg/http-response-status

Folders and files

NameName
Last commit message
Last commit date
Dec 2, 2023
Aug 18, 2019
Mar 1, 2020
Mar 1, 2020
Aug 18, 2019
Oct 13, 2019
Aug 18, 2019
Aug 18, 2019
Sep 21, 2024
Aug 18, 2019
Dec 18, 2022
Oct 22, 2019
Aug 18, 2019
Jun 6, 2022
May 29, 2023
Jun 2, 2022
Mar 30, 2020
Sep 21, 2024

Repository files navigation

http-response-status

HTTP Status Map

codecov Node.js CI release-please

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installing

Using npm:

npm i http-response-status

Using yarn:

yarn add http-response-status

Usage

Here are examples of how you can use http-response-status.

Check if it's a 200 OK

import { NHttpStatuses } from 'http-response-status'

const isOk = (httpCode: number) => {
  if (httpCode === NHttpStatuses.OK) {
    return true
  }

  return false
}

Get http status name

import { getHttpStatusName } from 'http-response-status'

const isOk = (httpCode: number) => {
  if (getHttpStatusName(httpCode) === 'OK') {
    return true
  }

  return false
}

Get http status category

import { HTTP_STATUS_SUCCESS, getHttpStatusCategory } from 'http-response-status'

const isSuccess = (httpCode: number) => {
  if (getHttpStatusCategory(httpCode) === HTTP_STATUS_SUCCESS) {
    return true
  }

  return false
}

Running the tests

Tests are written with jest

Type check

yarn run lint

Unit tests

yarn run test

Deployment

Deployment is done with Travis.

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details