feat: add record and replay proxy for automatic fixture generation#62
Open
mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
Open
feat: add record and replay proxy for automatic fixture generation#62mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
Conversation
Add `emulate record` command that proxies requests to real APIs, records the traffic, and generates an emulate.config.yaml with extracted seed entities on shutdown (Ctrl+C). Includes entity extractors for GitHub (users, repos) and Stripe (customers, products). Other services pass through the proxy but don't extract entities yet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
- Wrap upstream fetch() in try/catch to return 502 with error details instead of opaque 500 when upstream is unreachable - Strip trailing slashes from --upstream URL to prevent double-slash in constructed request URLs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Fixed both findings in 5b655d1:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
emulate recordcommand that proxies requests to real APIs, records the traffic, and generates anemulate.config.yamlwith extracted seed entities when you press Ctrl+C. Point your app at the local proxy, use it normally, and get a config file with realistic data.Why this matters
Setting up seed data for emulate requires manually writing YAML configs. For APIs with nested relationships (repos with issues, customers with payment methods), this is tedious and the resulting fixtures may not match real API response shapes.
Mockoon and WireMock both have recording proxy modes. This brings the same capability to emulate, with the added benefit of generating emulate-native seed configs rather than generic mock definitions.
Changes
packages/emulate/src/commands/record.ts: New command implementing the proxy server, traffic recording, and entity extraction. Includes extractors for GitHub (users, repos from response bodies) and Stripe (customers, products).packages/emulate/src/index.ts: Registered therecordcommand with--service,--upstream,--port, and--outputflagsREADME.mdandskills/emulate/SKILL.md: documented the new command with examples and flag referenceDemo
Shows the recording proxy starting, forwarding a request to GitHub's API, then generating a seed config on shutdown with the extracted user and repo entities.
How it works
--upstreamURL with original headersemulate.config.yamlEntity extraction is service-specific. Currently GitHub and Stripe have extractors. Other services proxy correctly but don't extract entities yet.
Testing
Existing tests pass. The proxy and entity extractors are pure functions that can be unit tested independently.
This contribution was developed with AI assistance (Claude Code).