Skip to content

Commit

Permalink
update the help for proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcelhaney committed May 23, 2024
1 parent faed043 commit 425e893
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-ravens-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"counterfact": minor
---

turn the proxy on or off for individual paths
6 changes: 2 additions & 4 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,9 @@ To proxy an individual endpoint, you can use the `$.proxy()` function.
};
```

To toggle globally between Counterfact and a proxy server, pass `--proxy-url <url>` in the CLI.
To set up a proxy for the entire API, add `--proxy <url>` in the CLI.

Then type `.proxy on` / `.proxy off` in the REPL to turn it on and off. When the global proxy is on, all requests will be sent to the proxy URL instead of the mock implementations in Counterfact.

This feature is hot off the presses and somewhat experimental. We have plans to introduce more granular controls over what gets proxied when, but we want to see how this works first. Please send feedback!
From there, you can switch back and forth between the proxy and mocks by typing `.proxy [on|off] <path-prefix>`. Type `.proxy help` for detailed information on using the `.proxy` command.

## No Cap Recap 🧢

Expand Down
2 changes: 1 addition & 1 deletion src/repl/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function startRepl(
action(text) {
if (text === "help" || text === "") {
print(".proxy [on|off] - turn the proxy on/off at the root level");
print(".proxy [on|off] <path> - turn the proxy on for a path");
print(".proxy [on|off] <path-prefix> - turn the proxy on for a path");
print(".proxy status - show the proxy status");
print(".proxy help - show this message");
} else if (text.startsWith("url")) {
Expand Down
2 changes: 1 addition & 1 deletion test/repl/repl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe("REPL", () => {

expect(harness.output).toEqual([
".proxy [on|off] - turn the proxy on/off at the root level",
".proxy [on|off] <path> - turn the proxy on for a path",
".proxy [on|off] <path-prefix> - turn the proxy on for a path",
".proxy status - show the proxy status",
".proxy help - show this message",
]);
Expand Down

0 comments on commit 425e893

Please sign in to comment.