Coder Social home page Coder Social logo

nguyentoanit / http-response-status Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arnaud-zg/http-response-status

0.0 1.0 0.0 691 KB

HTTP Status Map

Home Page: https://www.npmjs.com/package/http-response-status

License: MIT License

JavaScript 1.50% TypeScript 98.50%

http-response-status's Introduction

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

http-response-status's People

Contributors

renovate[bot] avatar arnaud-zg avatar dependabot[bot] avatar renovate-bot avatar github-actions[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.