Start
Deputy Server
npx @sayjava/deputy@latest
docker run -p 8080:8080 -p 8081:8081 sayjava/deputy
This command will:
Start mock API server at http://localhost:8080
Dashboard and REST API server at http://localhost:8081
Options
Configuration | Env Variable | Default | Description |
---|---|---|---|
--mocks-directory, -d | DEPUTY_MOCKS_DIRECTORY | mocks | Path to a folder containing yaml/json mock definition files |
--port, -p | DEPUTY_PORT | 8080 | The port the mock sever runs on |
--api-port, -ap | DEPUTY_API_PORT | 8081 | The port the api sever runs on |
--auto-proxy, -x | DEPUTY_AUTO_PROXY | true | Auto proxy requests ยง |
--tls-enabled, -tls | DEPUTY_TLS | undefined | Enables HTTPs and auto generates a self-signed certificate |
--tls-domains, -domains | DEPUTY_DOMAINS | undefined | Domain names that will be included in the certificate |
Initialize Mocks
When started, the server scan the mocks
folder if present in the current working directory and will attempt to load all .yml
or .json
files in that folder. See the Mock Definition.
an example hello_world.json
file looks like:
{
"request": {
"path": "/hello-word"
},
"response": {
"status": 200,
"body": "Hello"
}
}
now the server can be started by mounting the current folder into the server directory
npx @sayjava/deputy@latest --mocks-directory=mocks
docker run \
-p 8080:8080 \
-p 8081:8081 \
-v "${PWD}:/app/mocks" sayjava/deputy
HTTPS
Using the --tls
flag will start the mock server in https mode at https://localhost:8800
. Deputy server will auto generate a self signed certificate.
If Deputy detects a folder called ssl
in the current directory, it will use certificates in that folder with the names:
key.pem
cert.pem