{"id":20945178,"url":"https://github.com/tbxark/rmock","last_synced_at":"2025-08-21T12:33:00.496Z","repository":{"id":53729798,"uuid":"476124428","full_name":"TBXark/rmock","owner":"TBXark","description":"Modify HTTP JSON responses without needing HTTP capture and MitM.","archived":false,"fork":false,"pushed_at":"2024-09-13T01:45:53.000Z","size":253,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-13T14:42:17.431Z","etag":null,"topics":["cli-app","http-mock"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/TBXark.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":"2022-03-31T02:37:44.000Z","updated_at":"2024-09-13T01:45:51.000Z","dependencies_parsed_at":"2023-12-13T04:22:51.022Z","dependency_job_id":"57cd66b7-1bc3-45e2-9b79-f78cfbf84c33","html_url":"https://github.com/TBXark/rmock","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/TBXark%2Frmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TBXark%2Frmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TBXark%2Frmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TBXark%2Frmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TBXark","download_url":"https://codeload.github.com/TBXark/rmock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225269352,"owners_count":17447513,"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":["cli-app","http-mock"],"created_at":"2024-11-18T23:47:03.541Z","updated_at":"2024-11-18T23:47:04.103Z","avatar_url":"https://github.com/TBXark.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rmock\n\nModify the http json response, no need for http capture and MitM, and solutions of cross domain problems.\n\n### Install\n\n```shell\nnpm install -g https://github.com/TBXark/rmock.git\n```\n\n### Usage\n\n```\nUsage: rmock [options]\n\nOptions:\n  -p, --port \u003cport\u003e           port (default: 3000)\n  -t, --target \u003curl\u003e          target url (default: \"https://api.github.com\")\n  -tp, --targetPort \u003cport\u003e    target port\n  -c, --capture \u003call|none\u003e    capture all request or none (default: \"all\")\n  -r, --router \u003cpath\u003e         external router file (default: null)\n  -rh, --requestHeader        show request header (default: false)\n  -rb, --requestBody          show request body (default: true)\n  -res, --responseBody        show response body (default: true)\n  -pj, --prettyJson           print response json pretty (default: false)\n  -h --help                   read more information\n```\n\n\n### Example\n\n```js\n// example.js\n\n// Import core modules using require\n//\n// const os = require('os');\n// console.log(os.arch());\n\nasync function register(router, utils, importModule) {\n  // Commonly used functions are injected by default\n  //\n  //\n  const {mapJSON, customMapper, redirect} = utils; // eslint-disable-line\n\n  // Import custom modules using importModule\n  //\n  // get default export manually\n  const {default: fetch} = await importModule('node-fetch');\n  \n  // import internal modules\n  // const log = await importModule('./log.mjs');\n\n\n  // Example\n  //\n  //\n\n  // 1. disable some api log\n  router.get('/', mapJSON(null, {canLog: false}));\n\n  // 2. change response body\n  router.get('/status', mapJSON((res, ctx) =\u003e {\n    return {\n      ...res,\n      inject: 'Hello World!!!',\n    };\n  }));\n\n  // 3. async mapper\n  router.get('/users/:id', mapJSON(async (res, ctx) =\u003e {\n    const {id} = ctx.params;\n    const repos = await fetch(`https://api.github.com/users/${id}/repos`).then((res) =\u003e res.json());\n    return {\n      ...res,\n      repos,\n    };\n  }));\n}\n\n// use commonjs export\nexports.register = register;\n\n```\n\n\n```shell\nrmock -p 3000 -t https://api.github.com -c all -r example.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbxark%2Frmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbxark%2Frmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbxark%2Frmock/lists"}