{"id":15145727,"url":"https://github.com/soundcloud/intervene","last_synced_at":"2026-04-06T11:04:07.726Z","repository":{"id":38173707,"uuid":"252228193","full_name":"soundcloud/intervene","owner":"soundcloud","description":"A machine-in-the-middle proxy for development, enabling mocking and/or modification of API endpoints","archived":false,"fork":false,"pushed_at":"2025-01-07T15:06:02.000Z","size":1460,"stargazers_count":86,"open_issues_count":23,"forks_count":13,"subscribers_count":78,"default_branch":"master","last_synced_at":"2025-03-30T05:07:18.457Z","etag":null,"topics":[],"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/soundcloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2020-04-01T16:25:15.000Z","updated_at":"2025-03-20T04:33:24.000Z","dependencies_parsed_at":"2023-09-27T17:29:15.548Z","dependency_job_id":"d48016a8-a0c9-4fc5-9081-5cbeff7ee8e1","html_url":"https://github.com/soundcloud/intervene","commit_stats":{"total_commits":98,"total_committers":11,"mean_commits":8.909090909090908,"dds":0.5102040816326531,"last_synced_commit":"b69f517c0db5a551ff727140d592cf4818b090f4"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fintervene","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fintervene/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fintervene/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fintervene/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soundcloud","download_url":"https://codeload.github.com/soundcloud/intervene/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441057,"owners_count":20939239,"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-09-26T11:42:12.792Z","updated_at":"2026-04-06T11:04:07.695Z","avatar_url":"https://github.com/soundcloud.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intervene [![npm version](https://img.shields.io/npm/v/intervene)](https://www.npmjs.com/package/intervene) [![build status](https://img.shields.io/github/actions/workflow/status/soundcloud/intervene/run-tests.yml)](https://github.com/soundcloud/intervene/actions/workflows/run-tests.yml)\n\n_Hassle free HTTP(S) API proxying for development_\n\nQuickly mock endpoints in HTTP(S) APIs, edit requests and responses, proxy everything else to the real API.\n\nhttps://intervene.dev\n\n## Example\n\nLet's say you've got a website that accesses your API at https://mycompany.com/api.  There's a `GET /api/cat` that returns some JSON information (`name`, `color`, `image`) about a cat. You're planning a major update in the backend to add `GET /api/dog`. It's going to take the backend developers a few days to get that implemented, but you want to start work on the frontend already.\n\nRun this on the command line (Mac or Linux)\n\n`intervene create https://mycompany.com`\n\nIt's going to ask for admin privileges because it needs to override some things. It creates a file called `mycompany.com.ts`, which is an `intervene` config. Leave the process running and open the file.\n\n```typescript\nimport { ProxyConfig, routeBuilder } from '/Users/foo/Library/node_modules/intervene';\n\nconst config: ProxyConfig = {\n  target: 'https://mycompany.com',\n\n  routes: {\n\n    // Some example configurations follow\n    // ...\n\n  }\n};\n\nexport default config;\n```\n\n(Don't worry about path in the `import` statement. It's going to depend on how you installed `intervene`, but it is smart enough to automatically patch the path at runtime when importing the config)\n\nYou should see the site still works as normal (in chrome at least, you'll get a certificate warning in Firefox which you'll need to accept).  `GET /api/cat` still responds the same.\n\nNow let's change the configuration to include a new route:\n```typescript\n\nconst config: ProxyConfig = {\n  target: 'https://mycompany.com',\n\n  routes: {\n\n    '/api/dog': {\n      name: 'Fido',\n      color: 'Beige',\n      image: 'https://dogimages.com/bestdog.jpg'\n    }\n\n  }\n};\n```\n\nSave the file (no need to restart the `intervene` process, it will notice and restart itself.\n\nNow, if you `curl -k https://mycompany.com/api/dog`, you'll get the JSON specified in the file. `curl -k https://mycompany.com/api/cat` still responds the same, because it proxies through to the real `https://mycompany.com`.\n\n### Altering responses\n\nAnother update is planned to also return the `age` of the cat. You don't want to mock the whole endpoint, you just want to add the `age` property to whatever the real backend returns.\n\nLet's make a method endpoint.\n\n```typescript\n\nconst config: ProxyConfig = {\n  target: 'https://mycompany.com',\n\n  routes: {\n\n    '/api/dog': {\n      name: 'Fido',\n      color: 'Beige',\n      image: 'https://dogimages.com/bestdog.jpg'\n    },\n\n    '/api/cat': async (req, h, proxy) =\u003e {\n      const response = await proxy();\n      response.body.age = 7;\n      return response;\n    }\n\n  }\n};\n```\nSave the file again, and the https://mycompany.com/api/cat endpoint now has an added `age` property, with the rest of the response exactly as returned by the real server.\n\n### Documentation\n\nSee the documentation at https://intervene.dev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fintervene","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoundcloud%2Fintervene","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fintervene/lists"}