opusdev/vector-similarity-api
1
1# statuses2 3[![NPM Version][npm-version-image]][npm-url]4[![NPM Downloads][npm-downloads-image]][npm-url]5[![Node.js Version][node-version-image]][node-version-url]6[![Build Status][ci-image]][ci-url]7[![Test Coverage][coveralls-image]][coveralls-url]8[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]9 10HTTP status utility for node.11 12This module provides a list of status codes and messages sourced from13a few different projects:14 15 * The [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)16 * The [Node.js project](https://nodejs.org/)17 * The [NGINX project](https://www.nginx.com/)18 * The [Apache HTTP Server project](https://httpd.apache.org/)19 20## Installation21 22This is a [Node.js](https://nodejs.org/en/) module available through the23[npm registry](https://www.npmjs.com/). Installation is done using the24[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):25 26```sh27$ npm install statuses28```29 30## API31 32<!-- eslint-disable no-unused-vars -->33 34```js35var status = require('statuses')36```37 38### status(code)39 40Returns the status message string for a known HTTP status code. The code41may be a number or a string. An error is thrown for an unknown status code.42 43<!-- eslint-disable no-undef -->44 45```js46status(403) // => 'Forbidden'47status('403') // => 'Forbidden'48status(306) // throws49```50 51### status(msg)52 53Returns the numeric status code for a known HTTP status message. The message54is case-insensitive. An error is thrown for an unknown status message.55 56<!-- eslint-disable no-undef -->57 58```js59status('forbidden') // => 40360status('Forbidden') // => 40361status('foo') // throws62```63 64### status.codes65 66Returns an array of all the status codes as `Integer`s.67 68### status.code[msg]69 70Returns the numeric status code for a known status message (in lower-case),71otherwise `undefined`.72 73<!-- eslint-disable no-undef, no-unused-expressions -->74 75```js76status['not found'] // => 40477```78 79### status.empty[code]80 81Returns `true` if a status code expects an empty body.82 83<!-- eslint-disable no-undef, no-unused-expressions -->84 85```js86status.empty[200] // => undefined87status.empty[204] // => true88status.empty[304] // => true89```90 91### status.message[code]92 93Returns the string message for a known numeric status code, otherwise94`undefined`. This object is the same format as the95[Node.js http module `http.STATUS_CODES`](https://nodejs.org/dist/latest/docs/api/http.html#http_http_status_codes).96 97<!-- eslint-disable no-undef, no-unused-expressions -->98 99```js100status.message[404] // => 'Not Found'101```102 103### status.redirect[code]104 105Returns `true` if a status code is a valid redirect status.106 107<!-- eslint-disable no-undef, no-unused-expressions -->108 109```js110status.redirect[200] // => undefined111status.redirect[301] // => true112```113 114### status.retry[code]115 116Returns `true` if you should retry the rest.117 118<!-- eslint-disable no-undef, no-unused-expressions -->119 120```js121status.retry[501] // => undefined122status.retry[503] // => true123```124 125## License126 127[MIT](LICENSE)128 129[ci-image]: https://badgen.net/github/checks/jshttp/statuses/master?label=ci130[ci-url]: https://github.com/jshttp/statuses/actions?query=workflow%3Aci131[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/statuses/master132[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master133[node-version-image]: https://badgen.net/npm/node/statuses134[node-version-url]: https://nodejs.org/en/download135[npm-downloads-image]: https://badgen.net/npm/dm/statuses136[npm-url]: https://npmjs.org/package/statuses137[npm-version-image]: https://badgen.net/npm/v/statuses138[ossf-scorecard-badge]: https://api.securityscorecards.dev/projects/github.com/jshttp/statuses/badge139[ossf-scorecard-visualizer]: https://kooltheba.github.io/openssf-scorecard-api-visualizer/#/projects/github.com/jshttp/statuses140 