{"id":15492160,"url":"https://github.com/imjuni/jin-axios-curlize","last_synced_at":"2025-04-05T07:12:07.845Z","repository":{"id":176526375,"uuid":"658493770","full_name":"imjuni/jin-axios-curlize","owner":"imjuni","description":"AxiosRequestConfig to curl command","archived":false,"fork":false,"pushed_at":"2023-11-15T00:18:21.000Z","size":487,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T20:46:43.115Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/imjuni.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-25T22:44:23.000Z","updated_at":"2024-01-14T12:49:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"d65ad40d-cf92-487d-84a3-3069470cf79a","html_url":"https://github.com/imjuni/jin-axios-curlize","commit_stats":null,"previous_names":["imjuni/jin-axios-curlize"],"tags_count":3,"template":false,"template_full_name":"imjuni/typescript-cli-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjin-axios-curlize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjin-axios-curlize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjin-axios-curlize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fjin-axios-curlize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjuni","download_url":"https://codeload.github.com/imjuni/jin-axios-curlize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299850,"owners_count":20916193,"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":[],"created_at":"2024-10-02T07:59:12.058Z","updated_at":"2025-04-05T07:12:07.830Z","avatar_url":"https://github.com/imjuni.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jin-axios-curlize\n\n![ts](https://flat.badgen.net/badge/Built%20With/TypeScript/blue)\n[![Download Status](https://img.shields.io/npm/dw/jin-axios-curlize.svg?style=flat-square)](https://npmcharts.com/compare/jin-axios-curlize?minimal=true)\n[![Github Star](https://img.shields.io/github/stars/imjuni/jin-axios-curlize.svg?style=flat-square)](https://github.com/imjuni/jin-axios-curlize)\n[![Github Issues](https://img.shields.io/github/issues-raw/imjuni/jin-axios-curlize.svg?style=flat-square)](https://github.com/imjuni/jin-axios-curlize/issues)\n[![NPM version](https://img.shields.io/npm/v/jin-axios-curlize.svg?style=flat-square)](https://www.npmjs.com/package/jin-axios-curlize)\n[![License](https://img.shields.io/npm/l/jin-axios-curlize.svg?style=flat-square)](https://github.com/imjuni/jin-axios-curlize/blob/master/LICENSE)\n[![ci](https://github.com/imjuni/jin-axios-curlize/actions/workflows/ci.yml/badge.svg?style=flat-square)](https://github.com/imjuni/jin-axios-curlize/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/imjuni/jin-axios-curlize/branch/master/graph/badge.svg?style=flat-square\u0026token=R7R2PdJcS9)](https://codecov.io/gh/imjuni/jin-axios-curlize)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\njin-axios-curlize create curl command from AxiosRequestConfig.\n\nWhy?\n\n1. automatic create curl command from AxiosRequestConfig\n1. Quickly repeat error request\n1. Support querystring, header, body replacer\n1. work without intercepter, no need to request execute for curl command creation\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [installation](#installation)\n- [How to works?](#how-to-works)\n- [Usage](#usage)\n- [Options](#options)\n- [How do I add transaction id on querystring?](#how-do-i-add-transaction-id-on-querystring)\n- [jin-curlize](#jin-curlize)\n\n## installation\n\n```bash\nnpm install jin-axios-curlize --save-dev\n```\n\n## How to works?\n\n`jin-axios-curlize` create curl command from `AxiosRequestConfig`. For example,\n\n- `AxiosRequestConfig`.`headers` to `--header` option\n- `AxiosRequestConfig`.url and `AxiosRequestConfig`.params to querystring and href\n\n```mermaid\nflowchart LR\n    IMH[AxiosRequestConfig] --\u003e JC[jin-axios-curlize]\n    JC --\u003e C[curl command]\n```\n\n## Usage\n\n```ts\nimport axios, { AxiosRequestConfig } from 'axios';\nimport { createFromAxios } from 'jin-axios-curlize';\n\nconst req: AxiosRequestConfig = {\n  url: 'http://localhost:3000/v1/superhero/i-am-unique-id'\n  method: 'put',\n  data: {\n    name: 'ironman'\n  }\n}\n\nconst reply = await axios.request(req);\n\nconsole.log('curl command: ', createFromAxios(req));\n// curl -X PUT 'http://localhost:3000/v1/superhero/i-am-unique-id' -d $'{\"name\":\"ironman\"}'\n```\n\n## Options\n\n| Name                  | Requirement | Description                                                    |\n| --------------------- | ----------- | -------------------------------------------------------------- |\n| prettify              | require     | Apply prettifing. Add newline and backslash add on line-ending |\n| indent                | optional    | Only work on prettify set true, make space size                |\n| disableFollowRedirect | optional    | If set true, remove `--location` option from command           |\n| replacer.querystring  | optional    | replacer for querystring                                       |\n| replacer.body         | optional    | replacer for body                                              |\n| replacer.header       | optional    | replacer for header                                            |\n\n## How do I add transaction id on querystring?\n\n```ts\nimport { createV3, encodeQuerystring } from 'jin-curlize';\n\ncreateV3(req, {\n  prettify: false,\n  replacer: {\n    querystring: (qs) =\u003e {\n      const next = new URLSearchParams(qs);\n      // add your transaction id on querystring, `uuidgen` is linux or macosx uuid generator command\n      next.set('tid', `'\"$(uuidgen)\"'`);\n      return encodeQuerystring(next);\n    },\n  },\n});\n```\n\n## jin-curlize\n\nIf you want that curl command generate from FastifyRequest, use [jin-curlize](https://www.npmjs.com/package/jin-curlize) package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fjin-axios-curlize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjuni%2Fjin-axios-curlize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fjin-axios-curlize/lists"}