Skip to content

Commit 5be5f54

Browse files
committed
Update best practices for Dev Proxy v2.2.0
1 parent 8781465 commit 5be5f54

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

assets/best-practices.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
## Configuration files
44

5-
- Dev Proxy configuration file is named devproxyrc.json or devproxyrc.jsonc (if you want to include comments)
5+
- Dev Proxy configuration file is named devproxyrc.json, devproxyrc.jsonc (if you want to include comments), or devproxyrc.yaml/devproxyrc.yml (v2.2.0+)
66
- For clarity, store all Dev Proxy files in the .devproxy folder in the workspace
77
- When creating new configuration files, use the available tools to find out which Dev Proxy version the user has installed and use it. Schema version must match the installed Dev Proxy version.
8+
- When the user has Dev Proxy v2.2.0+, you can create YAML configuration files using `devproxy config new --format yaml`.
9+
- Use `devproxy config validate` (v2.2.0+) to validate configuration files before running Dev Proxy.
810
- If the project already has Dev Proxy files, use the same version for compatibility.
911
- Each Dev Proxy JSON file should include the schema in the `$schema` property. The file contents should be valid according to that schema.
1012
- In the configuration file, list the `plugins` first, followed by the `urlsToWatch` property, and plugins config sections if any.
@@ -35,6 +37,7 @@
3537
- When defining mock responses or CrudApiPlugin actions, put entries with the longest (most specific) URLs first. Entries are matched in the order they're defined, so you don't want a generic pattern like /{id} to override a more specific one like /category/{name}.
3638
- Mocks with the nth property should be defined first, because they're considered more specific than mocks without that property.
3739
- To return dynamic Retry-After header value in mock responses, use `@dynamic` as the header's value
40+
- To return a dynamic Retry-After header value with a specific initial value, use `@dynamic=initialvalue` (e.g. `@dynamic=120`) as the header's value (v2.2.0+). This is supported in GenericRandomErrorPlugin.
3841
- When simulating APIs and their responses, consider using the LatencyPlugin to make the API responses feel more realistic.
3942
- If you use the LatencyPlugin, put it before other plugins in the configuration file. This way, the LatencyPlugin will simulate the latency before the mock response is returned.
4043

@@ -45,9 +48,20 @@
4548
## Hot reload
4649

4750
- Dev Proxy supports hot reload of configuration files (v2.1.0+). When you modify the configuration file while Dev Proxy is running, it automatically detects the changes and restarts with the new configuration.
48-
- Hot reload works for the main configuration file (devproxyrc.json/devproxyrc.jsonc) and plugin-specific configuration files (mock files, CRUD API data files, etc.).
51+
- Hot reload works for the main configuration file (devproxyrc.json/devproxyrc.jsonc/devproxyrc.yaml/devproxyrc.yml) and plugin-specific configuration files (mock files, CRUD API data files, etc.).
4952
- You don't need to manually restart Dev Proxy after making configuration changes - just save the file and the changes take effect automatically.
5053
- Hot reload helps you iterate faster when developing and testing different proxy configurations.
54+
- To disable hot reload, use the `--no-watch` flag (v2.2.0+). This is useful when running Dev Proxy in CI/CD pipelines or automated environments where file watching is unnecessary.
55+
56+
## Detached mode
57+
58+
- Dev Proxy can run in detached (background) mode (v2.2.0+). This is useful for CI/CD pipelines, automated testing, and agent-driven workflows where Dev Proxy needs to run without an interactive terminal.
59+
- When running in detached mode, use `--output json` to get structured, machine-readable output that can be parsed by scripts and agents.
60+
61+
## Output format
62+
63+
- Use `--output json` (v2.2.0+) to get structured JSON output from Dev Proxy. This is ideal for automation, CI/CD pipelines, and agent-driven workflows.
64+
- Use `--output text` (default) for human-readable output in interactive terminal sessions.
5165

5266
## curl
5367

0 commit comments

Comments
 (0)