{"id":13448610,"url":"https://github.com/uyu423/r2curl","last_synced_at":"2025-06-11T00:35:16.604Z","repository":{"id":34863625,"uuid":"183194914","full_name":"uyu423/r2curl","owner":"uyu423","description":"Node.js Request Wrapper (axios, fetch, ..) to cURL Command String","archived":false,"fork":false,"pushed_at":"2023-01-07T05:09:34.000Z","size":1131,"stargazers_count":35,"open_issues_count":22,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T19:18:11.569Z","etag":null,"topics":["axios","curl"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/r2curl","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uyu423.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-24T09:25:58.000Z","updated_at":"2025-06-07T05:33:00.000Z","dependencies_parsed_at":"2023-01-15T09:39:49.132Z","dependency_job_id":null,"html_url":"https://github.com/uyu423/r2curl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uyu423%2Fr2curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uyu423%2Fr2curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uyu423%2Fr2curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uyu423%2Fr2curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uyu423","download_url":"https://codeload.github.com/uyu423/r2curl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uyu423%2Fr2curl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259136833,"owners_count":22810549,"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":["axios","curl"],"created_at":"2024-07-31T05:01:50.485Z","updated_at":"2025-06-11T00:35:16.573Z","avatar_url":"https://github.com/uyu423.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# r2curl\n\n[![npm version](https://badge.fury.io/js/r2curl.svg)](https://badge.fury.io/js/r2curl) [![Download Status](https://img.shields.io/npm/dw/r2curl.svg)](https://npmcharts.com/compare/r2curl?minimal=true) [![Github Star](https://img.shields.io/github/stars/uyu423/r2curl.svg?style=popout)](https://github.com/uyu423/r2curl)  [![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php) [![CircleCI](https://circleci.com/gh/uyu423/r2curl.svg?style=svg)](https://circleci.com/gh/uyu423/r2curl) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f74cdea970d44550a0bff9319e467256)](https://www.codacy.com/app/uyu423/r2curl?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=uyu423/r2curl\u0026amp;utm_campaign=Badge_Grade) [![Code Climate](https://codeclimate.com/github/uyu423/r2curl.svg)](https://codeclimate.com/github/uyu423/r2curl) [![Test Coverage](https://api.codeclimate.com/v1/badges/bb19fbd2394b545aefb2/test_coverage)](https://codeclimate.com/github/uyu423/r2curl/test_coverage)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"460\" src=\"./logo.png\"\u003e\n\u003c/p\u003e\n\n## Background\n\n- [r2curl](https://github.com/uyu423/r2curl) was inspired by [@delirius325/axios-curlirize](https://github.com/delirius325/axios-curlirize).\n- axios-curlirize is very convenient. but works as a middleware for axios, and I think this part is black box logic \n  - it contains potentially asynchronous concurrency issues and difficult-to-manage elements.\n- So I created a new 'Request to cURL' package that is completely independent of the dependencies of axios.\n\n## Feature\n\n- Generates cURL commands completely independently from the outside of the request wrapper package.\n- Provides additional options involved in generating the cURL command.\n- It will be updated soon to be available in packages like [node-fetch](https://www.npmjs.com/package/node-fetch) or [request](https://www.npmjs.com/package/request).\n\n## Roadmap\n\n  - [x] [axios](https://www.npmjs.com/package/axios)\n    - [x] AxiosRequestConfig\n    - [x] AxiosResposne\n  - [ ] [node-fetch](https://www.npmjs.com/package/node-fetch)\n  - [ ] [request](https://www.npmjs.com/package/request)\n  - [ ] ...\n\n## Install\n\n```bash\nnpm install r2curl --save\n```\n\n## Usage\n\n### axios\n\n#### `AxiosResponse`\n\n```typescript\n// if js, const r2curl = require('r2curl');\nimport r2curl from 'r2curl';\n\nconst response = await axios.get('https://google.com');\nconst curl = r2curl(response);\n\nconsole.log(curl);\n// stdout \"curl -X GET 'https://google.com' -H 'Accept:application/json, text/plain, */*' -H 'User-Agent:axios/0.18.0'\"\n```\n\n#### `AxiosRequestConfig`\n\n```typescript\n// if js, const r2curl = require('r2curl');\nimport r2curl from 'r2curl';\n\n// config as AxiosRequestConfig\nconst config = {\n  url: 'https://google.com',\n  method: 'POST',\n  data: {\n    caller: 'curl tester',\n  },\n  headers: {\n    'Content-Type': 'application/json',\n  },\n};\n\nconst curl = r2curl(reqeustConfig);\nconsole.log(curl);\n// stdout `curl -X POST 'https://google.com' -H 'Content-Type:application/json' --data '{\"caller\":\"curl tester\"}'`\n\nconst response = await axios.request(config);\n```\n\n### node-fetch\n\n- update soon (target 0.2.0)\n- see [github project board](https://github.com/uyu423/r2curl/projects/1)\n\n### request\n\n- update soon (target 0.2.0)\n- see [github project board](https://github.com/uyu423/r2curl/projects/1)\n\n## More `r2curl` Options\n\n### `option.quote`\n\n- Determines the type of quota around the body and uri.\n- default is `single`\n\n```typescript\nimport r2curl from 'r2curl';\n\n// option as IR2CurlOptions.ts\nconst option = {\n  /** Determines the type of quota around the body and uri. */\n  quote: 'double',\n};\n\nconst curl = r2curl(requestConfig, option);\nconsole.log(curl); \n```\n\n### `option.defaultContentType`\n\n- Determines the default Content-Type header value for `POST` and `PUT` requests.\n- default is `application/json; charset=utf-8`\n- Type is `(enum) HTTP_HEADER_CONTENT_TYPE` | `string` | `false`;\n- If you give `(boolean) false` to `defaultContentType`, you can disable `Content-Type` Header.\n\n```typescript\nimport r2curl, { HTTP_HEADER_CONTENT_TYPE } from 'r2curl';\n\n// const optionUsingEnum = {\n//   defaultContentType: HTTP_HEADER_CONTENT_TYPE.TEXT,\n// };\nconst option = {\n  defaultContentType: 'application/json5',\n}\nconst request: AxiosRequestConfig = { url: 'https://google.com', method: 'POST' };\n\nconst curl = r2curl(config, option);\nconsole.log(curl); \n// output: curl -X POST 'https://google.com' -H 'Content-Type:application/json5\n```\n\n### `option.forceBody`\n\n- Accept Body all HTTP Method.\n- By default, Body is not allowed in `GET` and `DELETE` methods.\n- However, some services such as ElasticSearch should be able to use the Body as a `GET` method. At this point, use this option to activate the Body.\n\n```typescript\nimport r2curl from 'r2curl';\n\nconst config: AxiosRequestConfig = {\n  url: 'https://google.com',\n  method: 'GET',\n  data: {\n    caller: 'https://github.com/uyu423/r2curl',\n    sorry: true,\n  },\n};\n\nconst option = {\n  forceBody: true,\n}\n\nconst curl = r2curl(config, option);\n// output: 'curl -X GET \\'https://google.com\\' --data \\'{\"caller\":\"https://github.com/uyu423/r2curl\",\"sorry\":true}\\''\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuyu423%2Fr2curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuyu423%2Fr2curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuyu423%2Fr2curl/lists"}