English | 中文
A test double that plays the whole show.
Stunt Double is a Rust-based mock server for integration testing against real external dependencies. It reads upstream APIs, transforms data with built-in JavaScript, returns files and binary responses, and runs with zero host runtime dependencies.
The configuration, ctx API, and CLI contracts are frozen for v1. The execution model and security boundaries live in plans/adr/; details live in docs/.
This quickstart uses a prebuilt release binary, so you do not need Rust/Cargo, GitHub CLI, Docker, or a source checkout. Download and verify the binary for your platform, then open a terminal in the extracted directory.
Create an empty files/ directory and save these two files beside the binary.
stuntdouble.toml:
config_version = "1"
[server]
bind = "127.0.0.1"
port = 3000
[files]
root = "./files"
[[routes]]
name = "hello"
method = "GET"
path = "/hello/:name"
script = "hello.js"hello.js:
const name = ctx.request.params.name;
ctx.respond(200, { "Content-Type": "text/plain; charset=utf-8" }, "Hello, " + name + "!\n");Validate the configuration and start the server from the extracted directory.
macOS or Linux:
./stuntdouble validate --config stuntdouble.toml
./stuntdouble serve --config stuntdouble.tomlWindows PowerShell:
.\stuntdouble.exe validate --config .\stuntdouble.toml
.\stuntdouble.exe serve --config .\stuntdouble.tomlOpen http://127.0.0.1:3000/hello/world in a browser. The response is:
Hello, world!
Press Ctrl-C to stop the server.
Next: Getting started walks through the first route in more detail; Mock recipes covers upstream, file, and upload flows.
Most mock tools are optimized for static stubs. Stunt Double targets the integration work static stubs cannot cover:
- Upstream APIs that return the data your client actually needs.
- CSV, JSON, text, and binary transformations via scripts.
- PDF, file, and byte-stream responses with Range support.
- CI environments where installing Node.js, Python, or a JVM is not acceptable.
| Tool | One-line position | Choose Stunt Double when you need |
|---|---|---|
| WireMock | Java-based general stubbing | Rust single binary plus upstream rewrite and binary streaming |
| Mockoon | Local static stubs and GUI | Scripted transforms plus Range/206 and zero-runtime CI |
| json-server | Resource-derived CRUD | Per-route declarations plus upstream and a file root |
| Prism | OpenAPI contract validation | A stand-in that reshapes real data before returning it |
For ordinary use, download a prebuilt binary; Rust and Cargo are not required. From the latest release, download both the archive and its matching .sha256 file. Keep them in the same folder, open a terminal or PowerShell there, and verify the checksum before extracting.
| Platform | Archive | SHA-256 file |
|---|---|---|
| Linux x86_64 | Download | Download |
| macOS Apple Silicon | Download | Download |
| Windows x64 | Download | Download |
The Linux and macOS commands below pass only the first line of the sidecar to the checksum tool, so an extra trailing blank line does not trigger a format warning.
head -n 1 stuntdouble-x86_64-unknown-linux-gnu.tar.gz.sha256 | sha256sum --check -
tar -xzf stuntdouble-x86_64-unknown-linux-gnu.tar.gz
cd stuntdouble-x86_64-unknown-linux-gnu
./stuntdouble --versionhead -n 1 stuntdouble-aarch64-apple-darwin.tar.gz.sha256 | shasum -a 256 -c -
tar -xzf stuntdouble-aarch64-apple-darwin.tar.gz
cd stuntdouble-aarch64-apple-darwin
./stuntdouble --version$expected = (Get-Content -Raw .\stuntdouble-x86_64-pc-windows-msvc.zip.sha256).Trim().Split(' ')[0]
$actual = (Get-FileHash .\stuntdouble-x86_64-pc-windows-msvc.zip -Algorithm SHA256).Hash
if ($actual -ne $expected) { throw "SHA-256 mismatch" }
"SHA-256 verified"
Expand-Archive -Path .\stuntdouble-x86_64-pc-windows-msvc.zip -DestinationPath .\stuntdouble-x86_64-pc-windows-msvc
Set-Location .\stuntdouble-x86_64-pc-windows-msvc
.\stuntdouble.exe --versionIf a checksum does not match, do not run the archive; download both files again and retry. The extracted directory contains the executable, so no installer or administrator access is needed.
The SHA-256 commands check that the archive matches the checksum published with the release. They do not verify how it was built. To verify the GitHub artifact attestation and build provenance, install the GitHub CLI (gh) separately, then run this with the archive you downloaded:
gh attestation verify stuntdouble-x86_64-unknown-linux-gnu.tar.gz --repo geeknonerd/stuntdoubleReplace the example filename with your downloaded archive. GitHub CLI is not required to install or run Stunt Double.
This option requires Docker. In stuntdouble.toml, keep your existing config_version and routes, and edit the existing [server] and [files] tables to use these values (do not add duplicate tables):
[server]
bind = "0.0.0.0"
port = 8080
[files]
root = "./files"Keep the referenced files/ directory and route scripts in the same project directory as stuntdouble.toml. From a macOS or Linux shell in that directory, run:
docker run --rm -p 127.0.0.1:8080:8080 \
-v "$PWD:/etc/stuntdouble:ro" \
ghcr.io/geeknonerd/stuntdouble:v1.0.3The image reads /etc/stuntdouble/stuntdouble.toml and serves on port 8080.
This path is for contributors with a repository checkout and a Rust toolchain:
cargo install --path .See docs/development.md for the full release asset list and release checklist.
- Route model with one pipeline:
match → source → transform → response. - Built-in JavaScript runtime (Boa) with a host-injected
ctx; no rawfetch,fs,os,subprocess, orsocket. - Upstream HTTP (
ctx.http.get, streamingctx.http.pipewith Range passthrough) plusctx.filereads, file streaming, opt-in atomic file writes, and request-scoped multipart uploads. - Host cryptography (
ctx.crypto.randomBytes,sha256,hmacSha256,timingSafeEqual) with secure random, SHA-256, HMAC-SHA256, and constant-time comparison. - v2 (unreleased): process-local
ctx.stateshared across requests in one server instance, with deep-copy reads, atomictake/setIfAbsent, per-key TTL, and fixed capacity; restart clears it. - One file root with path traversal and symlink-write protection; reads are always available, writes require
files.writable = trueand a per-request budget. - Linux x86_64, macOS arm64, and Windows x86_64 binaries plus
linux/amd64andlinux/arm64container images. - Structured per-request logs with
request_id, the upstream call chain, and stable error classes.
- Request-to-request shared state; response sequencing; automatic resource CRUD.
- TypeScript transpilation; Python runtime (v2, see ADR 0015); npm, pip, or third-party imports.
- Hot reload, Admin API, GUI; built-in TLS termination.
- WebSocket, GraphQL, gRPC.
ctx.http.request,retries,bodyBytes(deferred, see ADR 0016).
See plans/product-definition.md for the full scope.
- Getting started — install, first route, and upstream calls.
- Mock recipes — task-oriented JSON, upstream, file, upload, and CI examples.
- Public contracts — configuration,
ctxAPI, and CLI. ctxAPI type definitions — apiVersion 1 source types.- Demo fixture — runnable offline and upstream document scenarios.
- OAuth authorization mock — minimal OAuth 2.0 authorization code flow mock.
- Documentation site — rendered contracts and demo entry points.
- Changelog — release history.
Development documentation is written in Chinese; ADR 0013 records the language policy.
- Product definition (Chinese) — v1 scope, host API, non-goals.
- Development and release workflow (Chinese) — branch, commit, CI, versioning, and release rules.
- Architecture decisions (Chinese) — ADR index.
- Domain glossary (Chinese) — project vocabulary.
- Research (Chinese) — mock server landscape, runtimes, architecture, and open-source baseline.
- Repository documentation index (Chinese) — entry point for maintainers.
Before proposing a feature, read the product definition and the ADRs; new capabilities must still fit the single execution model. Follow the Code of Conduct, use the GitHub issue templates, keep customer data out of issues and fixtures, sign off with git commit -s (DCO), and keep commit messages in English. See CONTRIBUTING.md and docs/development.md.
Do not report vulnerabilities in a public issue. Use GitHub private vulnerability reporting for this repository. See SECURITY.md. Never paste customer hostnames, tokens, headers, production logs, request bodies, or response bodies into a public issue.
Dual-licensed under either of Apache-2.0 or MIT; you may choose either. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project is dual-licensed as above, without additional terms or conditions.
Host cryptography (ctx.crypto.randomBytes, sha256, hmacSha256, timingSafeEqual) with secure random, SHA-256, HMAC-SHA256, and constant-time comparison.