1.0.0 • Published 3 years ago

more-http-status-codes v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

more-http-status-codes

Yet an other library which implements its own version of HTTP response status codes.

The difference lies in its implementation:

  • fully documented (JSDocs and typescript)
  • supports import of categorized range of codes
  • and links to the RFC specifications

Of course there are no dependencies.

Installing and Usage

Using npm:

$ npm install more-http-status-codes

Using yarn:

$ yarn add more-http-status-codes
import HTTPStatusCodes, { SuccessfulCodes, ClientErrorCodes } from 'more-http-status-codes';

...
res.sendStatus(HTTPStatusCodes.OK);
// or
const data = {...}
res.status(SuccessfulCodes.CREATED).json(data)
// or
try{
    ...
} catch(e){
    res.sendStatus(ClientErrorCodes.BAD_REQUEST);
}

API

listSupportedCodesByNode = (supported = true): string[]
import { listSupportedCodesByNode } from 'more-http-status-codes';

// will list and return unsupported codes
listSupportedCodesByNode(false);

Sources