http-status-schema
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

HTTP Status Code

Introduction

This lib is for abstract errors code from Status Code, lib for transcode a string to status code.
Implement errors from HTTP Status Code.

Installation

This is a Node.js module available through the npm registry.

Use npm:

$ npm install http-status-schema

Use yarn:

$ yarn add http-status-schema

Features

  • Declarations Types of name status error for functions

Examples

First you need import the package for your project:

Convert string to status code:

import { selectStatus, StatusName } from 'http-status-schema';

const numberError =  selectStatus('201 Created'); // Convert the name of status to number
// Return 201

Create an interface for the status code:

import { selectStatus, StatusName } from 'http-status-schema';


class AppError {
  status: number;

  message: string;

  constructor(status: StatusName , message: string){
    this.status = selectStatus(status); // Convert the name of status to number
    this.message = message;
  }
}

This project is under the MIT license. See the LICENSE file for more details.

Package Sidebar

Install

npm i http-status-schema

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

44.3 kB

Total Files

17

Last publish

Collaborators

  • marconwillian