Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ Currently the library export just CurlGenerator, and it's a function with just 1
```js
/**
* @param {string} url - the request url
* @param {string} [param.method] - a value between ("GET" | "POST" | "PUT" | "PATCH" | "DELETE") it's case insensitive
* @param {string} [param.method] - a value between ("GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE" | "QUERY") it's case insensitive
* @param {Object<string, string>} [param.headers] - an object containing the headers of the request
* @param {Object} [body] - the body of the request
*/
```

Example of a more "andvanced" use
**Note:** The QUERY method is not yet an official HTTP standard but is based on an [IETF draft proposal](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-safe-method-w-body).

Example of a more "advanced" use
```js
import {CurlGenerator} from "curl-generator";

Expand Down
5 changes: 5 additions & 0 deletions dist/curl-generator.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ var getCurlMethod = function (method) {
PUT: "-X PUT",
PATCH: "-X PATCH",
DELETE: "-X DELETE",
HEAD: "-X HEAD",
OPTIONS: "-X OPTIONS",
CONNECT: "-X CONNECT",
TRACE: "-X TRACE",
QUERY: "-X QUERY",
};
result = " " + types[method.toUpperCase()];
}
Expand Down
5 changes: 5 additions & 0 deletions dist/curl-generator.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ var getCurlMethod = function (method) {
PUT: "-X PUT",
PATCH: "-X PATCH",
DELETE: "-X DELETE",
HEAD: "-X HEAD",
OPTIONS: "-X OPTIONS",
CONNECT: "-X CONNECT",
TRACE: "-X TRACE",
QUERY: "-X QUERY",
};
result = " " + types[method.toUpperCase()];
}
Expand Down
5 changes: 5 additions & 0 deletions dist/curl-generator.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
PUT: "-X PUT",
PATCH: "-X PATCH",
DELETE: "-X DELETE",
HEAD: "-X HEAD",
OPTIONS: "-X OPTIONS",
CONNECT: "-X CONNECT",
TRACE: "-X TRACE",
QUERY: "-X QUERY",
};
result = " " + types[method.toUpperCase()];
}
Expand Down
2 changes: 1 addition & 1 deletion dist/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare type CurlAdditionalOptions = {
verbose?: boolean;
};
declare type CurlRequest = {
method?: "GET" | "get" | "POST" | "post" | "PUT" | "put" | "PATCH" | "patch" | "DELETE" | "delete";
method?: "GET" | "get" | "POST" | "post" | "PUT" | "put" | "PATCH" | "patch" | "DELETE" | "delete" | "HEAD" | "head" | "OPTIONS" | "options" | "CONNECT" | "connect" | "TRACE" | "trace" | "QUERY" | "query";
headers?: StringMap;
body?: CurlBody;
url: string;
Expand Down
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type CurlAdditionalOptions = {
};

type CurlRequest = {
method?: "GET" | "get" | "POST" | "post" | "PUT" | "put" | "PATCH" | "patch" | "DELETE" | "delete",
// Query is not official HTTP method, but it's in a RFC and we want to support it. https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-safe-method-w-body
method?: "GET" | "get" | "POST" | "post" | "PUT" | "put" | "PATCH" | "patch" | "DELETE" | "delete" | "HEAD" | "head" | "OPTIONS" | "options" | "CONNECT" | "connect" | "TRACE" | "trace" | "QUERY" | "query",
headers?: StringMap,
body?: CurlBody,
url: string,
Expand All @@ -72,6 +73,11 @@ const getCurlMethod = function (method?: string): string {
PUT: "-X PUT",
PATCH: "-X PATCH",
DELETE: "-X DELETE",
HEAD: "-X HEAD",
OPTIONS: "-X OPTIONS",
CONNECT: "-X CONNECT",
TRACE: "-X TRACE",
QUERY: "-X QUERY",
};
result = ` ${types[method.toUpperCase()]}`;
}
Expand Down