Skip to content

Commit 03725fa

Browse files
initial commit
0 parents  commit 03725fa

30 files changed

+8220
-0
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: ["https://www.paypal.me/LorenzoPichilli"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/tmp
5+
/out-tsc
6+
/app-builds
7+
/release
8+
main.js
9+
src/**/*.js
10+
!src/karma.conf.js
11+
*.js.map
12+
13+
# dependencies
14+
node_modules
15+
16+
# IDEs and editors
17+
.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
32+
# misc
33+
/.angular/cache
34+
/.sass-cache
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
npm-debug.log
39+
testem.log
40+
/typings
41+
42+
# e2e
43+
/e2e/*.js
44+
!/e2e/protractor.conf.js
45+
/e2e/*.map
46+
/e2e/tracing
47+
/e2e/screenshots
48+
49+
# System Files
50+
.DS_Store
51+
Thumbs.db

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
Initial release

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License
2+
3+
Copyright 2022 Lorenzo Pichilli
4+
5+
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.
6+
7+
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.

README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<div align="center">
2+
3+
# HTTP Request Method Database
4+
5+
[![NPM](https://nodei.co/npm/http-request-method-db.png?compact=true)](https://nodei.co/npm/http-request-method-db/)
6+
<br />
7+
[![](https://img.shields.io/npm/dt/http-request-method-db.svg?style=flat-square)](https://www.npmjs.com/package/http-request-method-db)
8+
9+
</div>
10+
11+
[![NPM Version](https://badgen.net/npm/v/http-request-method-db)](https://npmjs.org/package/http-request-method-db)
12+
[![license](https://img.shields.io/github/license/pichillilorenzo/http-request-method-db)](/LICENSE)
13+
[![Donate to this project using Paypal](https://img.shields.io/badge/paypal-donate-yellow.svg)](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

Comments
 (0)