source: frontend/node_modules/statuses/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.8 KB
Line 
1# statuses
2
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 from
13a 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## Installation
21
22This is a [Node.js](https://nodejs.org/en/) module available through the
23[npm registry](https://www.npmjs.com/). Installation is done using the
24[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25
26```sh
27$ npm install statuses
28```
29
30## API
31
32<!-- eslint-disable no-unused-vars -->
33
34```js
35var status = require('statuses')
36```
37
38### status(code)
39
40Returns the status message string for a known HTTP status code. The code
41may be a number or a string. An error is thrown for an unknown status code.
42
43<!-- eslint-disable no-undef -->
44
45```js
46status(403) // => 'Forbidden'
47status('403') // => 'Forbidden'
48status(306) // throws
49```
50
51### status(msg)
52
53Returns the numeric status code for a known HTTP status message. The message
54is case-insensitive. An error is thrown for an unknown status message.
55
56<!-- eslint-disable no-undef -->
57
58```js
59status('forbidden') // => 403
60status('Forbidden') // => 403
61status('foo') // throws
62```
63
64### status.codes
65
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```js
76status['not found'] // => 404
77```
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```js
86status.empty[200] // => undefined
87status.empty[204] // => true
88status.empty[304] // => true
89```
90
91### status.message[code]
92
93Returns the string message for a known numeric status code, otherwise
94`undefined`. This object is the same format as the
95[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```js
100status.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```js
110status.redirect[200] // => undefined
111status.redirect[301] // => true
112```
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```js
121status.retry[501] // => undefined
122status.retry[503] // => true
123```
124
125## License
126
127[MIT](LICENSE)
128
129[ci-image]: https://badgen.net/github/checks/jshttp/statuses/master?label=ci
130[ci-url]: https://github.com/jshttp/statuses/actions?query=workflow%3Aci
131[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/statuses/master
132[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master
133[node-version-image]: https://badgen.net/npm/node/statuses
134[node-version-url]: https://nodejs.org/en/download
135[npm-downloads-image]: https://badgen.net/npm/dm/statuses
136[npm-url]: https://npmjs.org/package/statuses
137[npm-version-image]: https://badgen.net/npm/v/statuses
138[ossf-scorecard-badge]: https://api.securityscorecards.dev/projects/github.com/jshttp/statuses/badge
139[ossf-scorecard-visualizer]: https://kooltheba.github.io/openssf-scorecard-api-visualizer/#/projects/github.com/jshttp/statuses
Note: See TracBrowser for help on using the repository browser.