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

ConfigurationEnv VariableDefaultDescription
--mocks-directory, -dDEPUTY_MOCKS_DIRECTORYmocksPath to a folder containing yaml/json mock definition files
--port, -pDEPUTY_PORT8080The port the mock sever runs on
--api-port, -apDEPUTY_API_PORT8081The port the api sever runs on
--auto-proxy, -xDEPUTY_AUTO_PROXYtrueAuto proxy requests ยง
--tls-enabled, -tlsDEPUTY_TLSundefinedEnables HTTPs and auto generates a self-signed certificate
--tls-domains, -domainsDEPUTY_DOMAINSundefinedDomain 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
Edit this page on GitHub Updated at Wed, Jun 22, 2022