source: trip-planner-front/node_modules/statuses/README.md@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.4 KB
Line 
1# Statuses
2
3[![NPM Version][npm-image]][npm-url]
4[![NPM Downloads][downloads-image]][downloads-url]
5[![Node.js Version][node-version-image]][node-version-url]
6[![Build Status][travis-image]][travis-url]
7[![Test Coverage][coveralls-image]][coveralls-url]
8
9HTTP status utility for node.
10
11This module provides a list of status codes and messages sourced from
12a few different projects:
13
14 * The [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
15 * The [Node.js project](https://nodejs.org/)
16 * The [NGINX project](https://www.nginx.com/)
17 * The [Apache HTTP Server project](https://httpd.apache.org/)
18
19## Installation
20
21This is a [Node.js](https://nodejs.org/en/) module available through the
22[npm registry](https://www.npmjs.com/). Installation is done using the
23[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
24
25```sh
26$ npm install statuses
27```
28
29## API
30
31<!-- eslint-disable no-unused-vars -->
32
33```js
34var status = require('statuses')
35```
36
37### var code = status(Integer || String)
38
39If `Integer` or `String` is a valid HTTP code or status message, then the
40appropriate `code` will be returned. Otherwise, an error will be thrown.
41
42<!-- eslint-disable no-undef -->
43
44```js
45status(403) // => 403
46status('403') // => 403
47status('forbidden') // => 403
48status('Forbidden') // => 403
49status(306) // throws, as it's not supported by node.js
50```
51
52### status.STATUS_CODES
53
54Returns an object which maps status codes to status messages, in
55the same format as the
56[Node.js http module](https://nodejs.org/dist/latest/docs/api/http.html#http_http_status_codes).
57
58### status.codes
59
60Returns an array of all the status codes as `Integer`s.
61
62### var msg = status[code]
63
64Map of `code` to `status message`. `undefined` for invalid `code`s.
65
66<!-- eslint-disable no-undef, no-unused-expressions -->
67
68```js
69status[404] // => 'Not Found'
70```
71
72### var code = status[msg]
73
74Map of `status message` to `code`. `msg` can either be title-cased or
75lower-cased. `undefined` for invalid `status message`s.
76
77<!-- eslint-disable no-undef, no-unused-expressions -->
78
79```js
80status['not found'] // => 404
81status['Not Found'] // => 404
82```
83
84### status.redirect[code]
85
86Returns `true` if a status code is a valid redirect status.
87
88<!-- eslint-disable no-undef, no-unused-expressions -->
89
90```js
91status.redirect[200] // => undefined
92status.redirect[301] // => true
93```
94
95### status.empty[code]
96
97Returns `true` if a status code expects an empty body.
98
99<!-- eslint-disable no-undef, no-unused-expressions -->
100
101```js
102status.empty[200] // => undefined
103status.empty[204] // => true
104status.empty[304] // => true
105```
106
107### status.retry[code]
108
109Returns `true` if you should retry the rest.
110
111<!-- eslint-disable no-undef, no-unused-expressions -->
112
113```js
114status.retry[501] // => undefined
115status.retry[503] // => true
116```
117
118[npm-image]: https://img.shields.io/npm/v/statuses.svg
119[npm-url]: https://npmjs.org/package/statuses
120[node-version-image]: https://img.shields.io/node/v/statuses.svg
121[node-version-url]: https://nodejs.org/en/download
122[travis-image]: https://img.shields.io/travis/jshttp/statuses.svg
123[travis-url]: https://travis-ci.org/jshttp/statuses
124[coveralls-image]: https://img.shields.io/coveralls/jshttp/statuses.svg
125[coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master
126[downloads-image]: https://img.shields.io/npm/dm/statuses.svg
127[downloads-url]: https://npmjs.org/package/statuses
Note: See TracBrowser for help on using the repository browser.