{"id":22110821,"url":"https://github.com/megatolya/format-curl","last_synced_at":"2025-07-25T06:32:17.337Z","repository":{"id":57240381,"uuid":"119849971","full_name":"megatolya/format-curl","owner":"megatolya","description":"Create curl string from request params","archived":false,"fork":false,"pushed_at":"2018-10-31T17:48:35.000Z","size":75,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T07:17:56.362Z","etag":null,"topics":["curl","formatting"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/megatolya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-01T14:54:36.000Z","updated_at":"2021-09-09T12:41:30.000Z","dependencies_parsed_at":"2022-08-29T21:24:15.037Z","dependency_job_id":null,"html_url":"https://github.com/megatolya/format-curl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megatolya%2Fformat-curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megatolya%2Fformat-curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megatolya%2Fformat-curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megatolya%2Fformat-curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megatolya","download_url":"https://codeload.github.com/megatolya/format-curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227538264,"owners_count":17784606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","formatting"],"created_at":"2024-12-01T10:30:11.396Z","updated_at":"2024-12-01T10:30:11.949Z","avatar_url":"https://github.com/megatolya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# format-curl\nFormat curl execution from request params\n\n## Installation\nfrom npm\n\n```shell\nnpm install --save format-curl\n```\n\nfrom unpkg\n\n```html\n\u003cscript src=\"https://unpkg.com/format-curl@latest/dist/index.js\"\u003e\u003c/script\u003e\n\u003c!-- or --\u003e\n\u003cscript src=\"https://unpkg.com/format-curl@latest/dist/index.min.js\"\u003e\u003c/script\u003e\n\u003c!-- example --\u003e\n\u003cscript type=\"text/javascript\"\u003e\nconst curl = window.formatCurl({\n    href: 'http://my-host/pathname/',\n},\n{\n    args: ['-v'],\n    headers: {\n        'accept': '*/*',\n    },\n});\n\nconsole.log(curl);\n\u003c/script\u003e\n```\n\n## Usage\n```js\nimport curl from 'format-curl';\n\nconst url = 'https://myhost.com?param=value';\nconst options = {\n    headers: {\n        'x-header': 'test',\n        'x-header2': 'test2'\n    },\n    body: JSON.stringify({\n        param: '123'\n    }),\n    method: 'PUT',\n    args: ['-vvv']\n};\n\nconsole.log(curl(url, options));\n// curl -vvv \"https://myhost.com?param=value\" -H \"x-header: test\" -H \"x-header2: test2\" --data '{\"param\":\"123\"}' -X PUT\n```\n\nSee `test/index.test.js` for more examples!\n\n### API\n\n#### curl(url, [options])\n\nReturns a string with a resulting curl command.\n\n##### url\nType: `string` `Object`\n\nThe URL to request, as a string, a [WHATWG URL](https://nodejs.org/api/url.html#url_class_url) or [https.request options](https://nodejs.org/api/https.html#https_https_request_options_callback).\n\nIn case you provide partial or empty url it will use base url `http://localhost/` to fullfil it.\n\n##### options\nType: `Object`\n\n###### headers\nType: `Object`\n\nRequest headers.\n\n###### json\nType: `boolean`\n\nHelper for json format specific headers. Adds `accept` and `content-type` headers with `application/json` value in case they aren't presented.\n\n###### method\nType: `string`\n\nRequest method.\n\n###### body\nType: `string` `Object`\n\nRequest body. If you provide an object, it will be serialized via `JSON.stringify`.\n\n###### args\nType: `Array`\n\nCurl arguments. Like `-vvv`, `-k`, `-L` and etc.\n\n## Publish\n\nBuild package and publish under `beta` tag:\n\n```bash\nnpm run build \u0026\u0026 npm publish --tag beta\n```\n\nNow you can install it using published version (`npm install format-curl@\u003cversion\u003e`) and test it. When you finish, add a `latest` tag to the published version:\n\n```bash\nnpm dist-tag rm format-curl beta\nnpm dist-tag add format-curl@\u003cversion\u003e latest\n```\n\n## TODO\n* user-argent, cookies as a params (and as curl arguments)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegatolya%2Fformat-curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegatolya%2Fformat-curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegatolya%2Fformat-curl/lists"}