|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# HTTP Request Method Database |
| 4 | + |
| 5 | +[](https://nodei.co/npm/http-request-method-db/) |
| 6 | +<br /> |
| 7 | +[](https://www.npmjs.com/package/http-request-method-db) |
| 8 | + |
| 9 | +</div> |
| 10 | + |
| 11 | +[](https://npmjs.org/package/http-request-method-db) |
| 12 | +[](/LICENSE) |
| 13 | +[](https://www.paypal.me/LorenzoPichilli) |
| 14 | + |
| 15 | +This is a database of known HTTP Request Methods and information about them. It consists of a single, public JSON file and does not include any logic, allowing it to remain as un-opinionated as possible with an API. It aggregates data from the following sources: |
| 16 | + |
| 17 | +- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +npm i --save http-request-method-db |
| 23 | +``` |
| 24 | + |
| 25 | +### Database Download |
| 26 | + |
| 27 | +If you want download the database and use it directly in the browser, you can just grab the |
| 28 | +JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to |
| 29 | +replace `main` with [a release tag](https://github.com/pichillilorenzo/http-request-method-db/tags) |
| 30 | +as the JSON format may change in the future. |
| 31 | + |
| 32 | +``` |
| 33 | +https://cdn.jsdelivr.net/gh/pichillilorenzo/http-request-method-db@main/dist/db.json |
| 34 | +``` |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +```js |
| 39 | +import db from 'http-request-method-db'; |
| 40 | +// .. or |
| 41 | +const db = require('http-request-method-db'); |
| 42 | + |
| 43 | +const getInfo = db['get']; // An instance of HTTPRequestMethod |
| 44 | +console.log(getInfo.syntax); // GET /index.html |
| 45 | +``` |
| 46 | + |
| 47 | +Access HTTP Request Method info using the request method name in **lower case** as key. |
| 48 | + |
| 49 | +## Contributing |
| 50 | + |
| 51 | +The primary way to contribute to this database is by updating the data in one of the upstream sources. |
| 52 | +Check the `scripts/src/mdn-scraper.ts` to check the MDN scraper implementation. |
| 53 | + |
| 54 | +### Direct Inclusion |
| 55 | + |
| 56 | +If that is not possible / feasible, they can be added directly here as a "custom" request method. |
| 57 | + |
| 58 | +To edit the database, only make PRs against `scripts/src/custom-request-methods.json`. |
| 59 | + |
| 60 | +The `scripts/src/custom-request-methods.json` file is a JSON object of type [HTTPRequestMethodDb](https://pichillilorenzo.github.io/http-request-method-db/interfaces/HTTPRequestMethodDb.html), where each `key` is the request method name in lower case and the `value` |
| 61 | +is an Object of type [HTTPRequestMethod](https://pichillilorenzo.github.io/http-request-method-db/interfaces/HTTPRequestMethod.html). |
| 62 | + |
| 63 | +To update the build, run `npm run build:all`. |
| 64 | + |
| 65 | +## HTTPRequestMethodDb Data Structure Example |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "connect": {...}, |
| 70 | + "get": { |
| 71 | + "name": "GET", |
| 72 | + "description": "The HTTP GET method requests a representation of the specified resource. Requests using GET should only be used to request data (they shouldn't include data). Note: Sending body/payload in a GET request may cause some existing implementations to reject the request — while not prohibited by the specification, the semantics are undefined. It is better to just avoid sending payloads in GET requests.", |
| 73 | + "note": "Note: Sending body/payload in a GET request may cause some existing implementations to reject the request — while not prohibited by the specification, the semantics are undefined. It is better to just avoid sending payloads in GET requests.", |
| 74 | + "syntax": "GET /index.html", |
| 75 | + "link": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET", |
| 76 | + "requestHasBody": false, |
| 77 | + "successfulResponseHasBody": true, |
| 78 | + "safe": true, |
| 79 | + "idempotent": true, |
| 80 | + "cacheable": true, |
| 81 | + "examples": [], |
| 82 | + "specifications": [ |
| 83 | + { |
| 84 | + "name": "HTTP Semantics # GET", |
| 85 | + "link": "https://httpwg.org/specs/rfc9110.html#GET" |
| 86 | + } |
| 87 | + ], |
| 88 | + "browserCompatibility": [ |
| 89 | + { |
| 90 | + "name": "Chrome", |
| 91 | + "supported": true, |
| 92 | + "version": "Yes" |
| 93 | + }, |
| 94 | + { |
| 95 | + "name": "Edge", |
| 96 | + "supported": true, |
| 97 | + "version": "12" |
| 98 | + }, |
| 99 | + { |
| 100 | + "name": "Firefox", |
| 101 | + "supported": true, |
| 102 | + "version": "Yes" |
| 103 | + }, |
| 104 | + { |
| 105 | + "name": "Opera", |
| 106 | + "supported": true, |
| 107 | + "version": "Yes" |
| 108 | + }, |
| 109 | + { |
| 110 | + "name": "Safari", |
| 111 | + "supported": true, |
| 112 | + "version": "Yes" |
| 113 | + }, |
| 114 | + { |
| 115 | + "name": "Chrome Android", |
| 116 | + "supported": true, |
| 117 | + "version": "Yes" |
| 118 | + }, |
| 119 | + { |
| 120 | + "name": "Firefox for Android", |
| 121 | + "supported": true, |
| 122 | + "version": "Yes" |
| 123 | + }, |
| 124 | + { |
| 125 | + "name": "Opera Android", |
| 126 | + "supported": true, |
| 127 | + "version": "Yes" |
| 128 | + }, |
| 129 | + { |
| 130 | + "name": "Safari on iOS", |
| 131 | + "supported": true, |
| 132 | + "version": "Yes" |
| 133 | + }, |
| 134 | + { |
| 135 | + "name": "Samsung Internet", |
| 136 | + "supported": true, |
| 137 | + "version": "Yes" |
| 138 | + }, |
| 139 | + { |
| 140 | + "name": "WebView Android", |
| 141 | + "supported": true, |
| 142 | + "version": "Yes" |
| 143 | + } |
| 144 | + ] |
| 145 | + }, |
| 146 | + "head": {...}, |
| 147 | + ... |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +Check [HTTPRequestMethodDb](https://pichillilorenzo.github.io/http-request-method-db/interfaces/HTTPRequestMethodDb.html) for more details. |
| 152 | + |
| 153 | +## License |
| 154 | + |
| 155 | +Released under the [ISC](/LICENSE) license. |
| 156 | + |
| 157 | +This project is strongly inspired by the [mime-db](https://github.com/jshttp/mime-db). |
0 commit comments