diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..109e317 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: ["https://www.paypal.me/LorenzoPichilli"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1729a45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,51 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/tmp +/out-tsc +/app-builds +/release +main.js +src/**/*.js +!src/karma.conf.js +*.js.map + +# dependencies +node_modules + +# IDEs and editors +.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.angular/cache +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +!/e2e/protractor.conf.js +/e2e/*.map +/e2e/tracing +/e2e/screenshots + +# System Files +.DS_Store +Thumbs.db diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9d241d4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +Initial release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d323974 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +ISC License + +Copyright 2022 Lorenzo Pichilli + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a7127e --- /dev/null +++ b/README.md @@ -0,0 +1,157 @@ +
+ +# HTTP Request Method Database + +[![NPM](https://nodei.co/npm/http-request-method-db.png?compact=true)](https://nodei.co/npm/http-request-method-db/) +
+[![](https://img.shields.io/npm/dt/http-request-method-db.svg?style=flat-square)](https://www.npmjs.com/package/http-request-method-db) + +
+ +[![NPM Version](https://badgen.net/npm/v/http-request-method-db)](https://npmjs.org/package/http-request-method-db) +[![license](https://img.shields.io/github/license/pichillilorenzo/http-request-method-db)](/LICENSE) +[![Donate to this project using Paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/LorenzoPichilli) + +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: + +- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods + +## Installation + +```bash +npm i --save http-request-method-db +``` + +### Database Download + +If you want download the database and use it directly in the browser, you can just grab the +JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to +replace `main` with [a release tag](https://github.com/pichillilorenzo/http-request-method-db/tags) +as the JSON format may change in the future. + +``` +https://cdn.jsdelivr.net/gh/pichillilorenzo/http-request-method-db@main/dist/db.json +``` + +## Usage + +```js +import db from 'http-request-method-db'; +// .. or +const db = require('http-request-method-db'); + +const getInfo = db['get']; // An instance of HTTPRequestMethod +console.log(getInfo.syntax); // GET /index.html +``` + +Access HTTP Request Method info using the request method name in **lower case** as key. + +## Contributing + +The primary way to contribute to this database is by updating the data in one of the upstream sources. +Check the `scripts/src/mdn-scraper.ts` to check the MDN scraper implementation. + +### Direct Inclusion + +If that is not possible / feasible, they can be added directly here as a "custom" request method. + +To edit the database, only make PRs against `scripts/src/custom-request-methods.json`. + +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` +is an Object of type [HTTPRequestMethod](https://pichillilorenzo.github.io/http-request-method-db/interfaces/HTTPRequestMethod.html). + +To update the build, run `npm run build:all`. + +## HTTPRequestMethodDb Data Structure Example + +```json +{ + "connect": {...}, + "get": { + "name": "GET", + "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.", + "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.", + "syntax": "GET /index.html", + "link": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET", + "requestHasBody": false, + "successfulResponseHasBody": true, + "safe": true, + "idempotent": true, + "cacheable": true, + "examples": [], + "specifications": [ + { + "name": "HTTP Semantics # GET", + "link": "https://httpwg.org/specs/rfc9110.html#GET" + } + ], + "browserCompatibility": [ + { + "name": "Chrome", + "supported": true, + "version": "Yes" + }, + { + "name": "Edge", + "supported": true, + "version": "12" + }, + { + "name": "Firefox", + "supported": true, + "version": "Yes" + }, + { + "name": "Opera", + "supported": true, + "version": "Yes" + }, + { + "name": "Safari", + "supported": true, + "version": "Yes" + }, + { + "name": "Chrome Android", + "supported": true, + "version": "Yes" + }, + { + "name": "Firefox for Android", + "supported": true, + "version": "Yes" + }, + { + "name": "Opera Android", + "supported": true, + "version": "Yes" + }, + { + "name": "Safari on iOS", + "supported": true, + "version": "Yes" + }, + { + "name": "Samsung Internet", + "supported": true, + "version": "Yes" + }, + { + "name": "WebView Android", + "supported": true, + "version": "Yes" + } + ] + }, + "head": {...}, + ... +} +``` + +Check [HTTPRequestMethodDb](https://pichillilorenzo.github.io/http-request-method-db/interfaces/HTTPRequestMethodDb.html) for more details. + +## License + +Released under the [ISC](/LICENSE) license. + +This project is strongly inspired by the [mime-db](https://github.com/jshttp/mime-db). diff --git a/dist/db.json b/dist/db.json new file mode 100644 index 0000000..1bbae4e --- /dev/null +++ b/dist/db.json @@ -0,0 +1 @@ +{"connect":{"name":"CONNECT","description":"The HTTP CONNECT method starts two-way communications with the requested resource. It can be used to open a tunnel. For example, the CONNECT method can be used to access websites that use SSL (HTTPS). The client asks an HTTP Proxy server to tunnel the TCP connection to the desired destination. The server then proceeds to make the connection on behalf of the client. Once the connection has been established by the server, the Proxy server continues to proxy the TCP stream to and from the client. CONNECT is a hop-by-hop method.","syntax":"CONNECT www.example.com:443 HTTP/1.1","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT","requestHasBody":false,"successfulResponseHasBody":true,"safe":false,"idempotent":false,"cacheable":false,"examples":["CONNECT server.example.com:80 HTTP/1.1\nHost: server.example.com:80\nProxy-Authorization: basic aGVsbG86d29ybGQ="],"specifications":[{"name":"HTTP Semantics # CONNECT","link":"https://httpwg.org/specs/rfc9110.html#CONNECT"}],"browserCompatibility":[{"name":"Chrome","supported":true,"version":"Yes"},{"name":"Edge","supported":true,"version":"12"},{"name":"Firefox","supported":true,"version":"Yes"},{"name":"Opera","supported":true,"version":"Yes"},{"name":"Safari","supported":true,"version":"Yes"},{"name":"Chrome Android","supported":true,"version":"Yes"},{"name":"Firefox for Android","supported":true,"version":"Yes"},{"name":"Opera Android","supported":true,"version":"Yes"},{"name":"Safari on iOS","supported":true,"version":"Yes"},{"name":"Samsung Internet","supported":true,"version":"Yes"},{"name":"WebView Android","supported":true,"version":"Yes"}]},"delete":{"name":"DELETE","description":"The HTTP DELETE request method deletes the specified resource.","syntax":"DELETE /file.html HTTP/1.1","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE","requestHasBody":false,"successfulResponseHasBody":false,"safe":false,"idempotent":true,"cacheable":false,"examples":[],"specifications":[{"name":"HTTP Semantics # DELETE","link":"https://httpwg.org/specs/rfc9110.html#DELETE"}],"browserCompatibility":[{"name":"Chrome","supported":true,"version":"Yes"},{"name":"Edge","supported":true,"version":"12"},{"name":"Firefox","supported":true,"version":"Yes"},{"name":"Opera","supported":true,"version":"Yes"},{"name":"Safari","supported":true,"version":"Yes"},{"name":"Chrome Android","supported":true,"version":"Yes"},{"name":"Firefox for Android","supported":true,"version":"Yes"},{"name":"Opera Android","supported":true,"version":"Yes"},{"name":"Safari on iOS","supported":true,"version":"Yes"},{"name":"Samsung Internet","supported":true,"version":"Yes"},{"name":"WebView Android","supported":true,"version":"Yes"}]},"get":{"name":"GET","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.","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.","syntax":"GET /index.html","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET","requestHasBody":false,"successfulResponseHasBody":true,"safe":true,"idempotent":true,"cacheable":true,"examples":[],"specifications":[{"name":"HTTP Semantics # GET","link":"https://httpwg.org/specs/rfc9110.html#GET"}],"browserCompatibility":[{"name":"Chrome","supported":true,"version":"Yes"},{"name":"Edge","supported":true,"version":"12"},{"name":"Firefox","supported":true,"version":"Yes"},{"name":"Opera","supported":true,"version":"Yes"},{"name":"Safari","supported":true,"version":"Yes"},{"name":"Chrome Android","supported":true,"version":"Yes"},{"name":"Firefox for Android","supported":true,"version":"Yes"},{"name":"Opera Android","supported":true,"version":"Yes"},{"name":"Safari on iOS","supported":true,"version":"Yes"},{"name":"Samsung Internet","supported":true,"version":"Yes"},{"name":"WebView Android","supported":true,"version":"Yes"}]},"head":{"name":"HEAD","description":"The HTTP HEAD method requests the headers that would be returned if the HEAD request's URL was instead requested with the HTTP GET method. For example, if a URL might produce a large download, a HEAD request could read its Content-Length header to check the filesize without actually downloading the file. Warning: A response to a HEAD method should not have a body. If it has one anyway, that body must be ignored: any representation headers that might describe the erroneous body are instead assumed to describe the response which a similar GET request would have received. If the response to a HEAD request shows that a cached URL response is now outdated, the cached copy is invalidated even if no GET request was made.","syntax":"HEAD /index.html","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD","requestHasBody":false,"successfulResponseHasBody":false,"safe":true,"idempotent":true,"cacheable":true,"warning":"Warning: A response to a HEAD method should not have a body. If it has one anyway, that body must be ignored: any representation headers that might describe the erroneous body are instead assumed to describe the response which a similar GET request would have received.","examples":[],"specifications":[{"name":"HTTP Semantics # HEAD","link":"https://httpwg.org/specs/rfc9110.html#HEAD"}],"browserCompatibility":[{"name":"Chrome","supported":true,"version":"Yes"},{"name":"Edge","supported":true,"version":"12"},{"name":"Firefox","supported":true,"version":"Yes"},{"name":"Opera","supported":true,"version":"Yes"},{"name":"Safari","supported":true,"version":"Yes"},{"name":"Chrome Android","supported":true,"version":"Yes"},{"name":"Firefox for Android","supported":true,"version":"Yes"},{"name":"Opera Android","supported":true,"version":"Yes"},{"name":"Safari on iOS","supported":true,"version":"Yes"},{"name":"Samsung Internet","supported":true,"version":"Yes"},{"name":"WebView Android","supported":true,"version":"Yes"}]},"options":{"name":"OPTIONS","description":"The HTTP OPTIONS method requests permitted communication options for a given URL or server. A client can specify a URL with this method, or an asterisk (*) to refer to the entire server.","syntax":"OPTIONS /index.html HTTP/1.1\nOPTIONS * HTTP/1.1","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS","requestHasBody":false,"successfulResponseHasBody":true,"safe":true,"idempotent":true,"cacheable":false,"examples":[],"specifications":[{"name":"HTTP Semantics # OPTIONS","link":"https://httpwg.org/specs/rfc9110.html#OPTIONS"}],"browserCompatibility":[{"name":"Chrome","supported":true,"version":"Yes"},{"name":"Edge","supported":true,"version":"12"},{"name":"Firefox","supported":true,"version":"Yes"},{"name":"Opera","supported":true,"version":"Yes"},{"name":"Safari","supported":true,"version":"Yes"},{"name":"Chrome Android","supported":true,"version":"Yes"},{"name":"Firefox for Android","supported":true,"version":"Yes"},{"name":"Opera Android","supported":true,"version":"Yes"},{"name":"Safari on iOS","supported":true,"version":"Yes"},{"name":"Samsung Internet","supported":true,"version":"Yes"},{"name":"WebView Android","supported":true,"version":"Yes"}]},"patch":{"name":"PATCH","description":"The HTTP PATCH request method applies partial modifications to a resource. PATCH is somewhat analogous to the \"update\" concept found in CRUD (in general, HTTP is different than CRUD, and the two should not be confused). A PATCH request is considered a set of instructions on how to modify a resource. Contrast this with PUT; which is a complete representation of a resource. A PATCH is not necessarily idempotent, although it can be. Contrast this with PUT; which is always idempotent. The word \"idempotent\" means that any number of repeated, identical requests will leave the resource in the same state. For example if an auto-incrementing counter field is an integral part of the resource, then a PUT will naturally overwrite it (since it overwrites everything), but not necessarily so for PATCH. PATCH (like POST) may have side-effects on other resources. To find out whether a server supports PATCH, a server can advertise its support by adding it to the list in the Allow or Access-Control-Allow-Methods (for CORS) response headers. Another (implicit) indication that PATCH is allowed, is the presence of the Accept-Patch header, which specifies the patch document formats accepted by the server.","syntax":"PATCH /file.txt HTTP/1.1","link":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH","requestHasBody":true,"successfulResponseHasBody":true,"safe":false,"idempotent":false,"cacheable":false,"examples":[],"specifications":[{"name":"RFC 5789","link":"https://www.rfc-editor.org/rfc/rfc5789"}],"browserCompatibility":[]},"post":{"name":"POST","description":"The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header. The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), where successive identical POST may have additional effects, like passing an order several times. A POST request is typically sent via an HTML form and results in a change on the server. In this case, the content type is selected by putting the adequate string in the enctype attribute of the
element or the formenctype attribute of the or