Skip to content

Commit

Permalink
docs: some docs improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Ottun committed Oct 7, 2021
1 parent a923948 commit cdf1ac1
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 70 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build

on:
push:
paths:
- '!docs/**'
branches: [ main ]

env:
Expand Down
35 changes: 12 additions & 23 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
---
home: true
heroImage: /assets/img/landing.svg
tagline: A robust HTTP mocking server to rapidly aid application development and system testing
tagline: A robust HTTP mocking server that aids application development, inspection and testing
actionText: Get Started →
actionLink: /start/
features:
- title: Develop
details: Simulate non-ready/remote APIs with an easy declarative system
- title: Inspect
details: By proxying requests automatically, devs can inspect and visualize network requests by system under test
details: Transparently mock non-ready/remote HTTP APIs with an easy declarative system
- title: Proxy & Inspect
details: Automatically proxy requests to remote servers. Developers can inspect and visualize network requests by application under test
- title: Test
details: Assert HTTP requests made from system under test using a RESTful API
details: Assert HTTP requests made from application under test using a RESTful API
footer: MIT Licensed
---

## Quick Start
Create a file mock.yml
```yaml
- request:
path: /hello
response:
statusCode: 200
body:
name: John Doe
job: developer
### Sample Environment

```
Selectively mock APIs, Deputy server will transparently forward unmatched requests to remote systems
![media/dev_environment](./media/dev_environment.png)

### Quick Start
```bash
npx @sayjava/behave
docker run -p 8080:8080 ghcr.io/sayjava/deputy
```

<!-- or -->

```bash
docker run -p 8080:8080 ghcr.io/sayjava/behave
$ curl http://localhost:8080/whoami
```

```bash
$ curl http://localhost:8080/whoami
```
Visit the dashboard at `http://localhost:8080/_/dashboard`
Binary file added docs/media/dev_environment.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 0 additions & 29 deletions docs/media/test.svg

This file was deleted.

Binary file added docs/media/test_environment.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 48 additions & 16 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ title: Quick Start
## Start Server

```shell
npx @sayjava/behave
docker run -p 8080:8080 ghcr.io/sayjava/deputy
```

This will start the sever on port `8080` and ready to receive requests at `http://localhost:8080`.
This will start the server on port `8080` and ready to receive requests at `http://localhost:8080`.

## Server Options

| Configuration | Env Variable | Default | Description |
| :------------------ | :----------- | :----------- | :------------- | :------------------------------------------------------------------- |
| \--from-file, -f | BEHAVE_FILE | behaviors.yaml | Path to a YAML file containing an array of behaviors | BEHAVE_PORT
| \--port, -p | BEHAVE_HEALTH_CHECK | 8080 | The port the sever should listen on BEHAVE_READY_CHECK |
| \--healthCheck, -he | | /\_/healthz | The keep-live path for the server |
| \--readyCheck, -re | | /\_/readyz | The ready path for the server |
| \--https, -s | | false | Enable https. There must be an ssl folder with `key.pem` and `cert.pem` files present |
| Configuration | Env Variable | Default | Description |
| :------------------ | :----------- | :------------- | :------------- |
| \--from-file, -f | DEPUTY_FILE | mocks.yml | Path to a YAML file containing defined mocks |
| \--port, -p | DEPUTY_PORT | 8080 | The port the se |

## Initialize Behaviors
## Initialize Mocks

When started, the server will look for a filed called `behaviors.yaml` in the current working directory and will load all the behaviors defined in the file see the [Behavior Document](/guide).
When started, the server will look for a filed called `mocks.yaml` in the current working directory and will load all the behaviors defined in the file see the [Mock Definition](/guide).

an example `behaviors.yaml` file looks like:
an example `mocks.yaml` file looks like:

```yaml
- request:
path: /hi
response:
body: Hello World

```

by just running

```shell
npx @sayjava/behave
docker run \
-p 8080:8080 \
-v "${PWD}:/app/mocks/fixtures" \
--rm --name deputy \
ghcr.io/sayjava/deputy
```

The server will auto load the behaviors in the file.
Expand All @@ -52,7 +52,39 @@ The server uses the environmental variable `NODE_LOG_LEVEL` to enable logging. P
- `DEBUG`
- `ERROR`

## Programmatic

## Sample Setups
There are different ways to setup a dev environment with Deputy. Here are a few example

### A Simple NodeJS Application
```javascript
const http = require('https')

http.get('httsp')
```

```bash
curl -X GET app
```

<!-- ![NodeJS](./media/nodejs.svg) -->

### Docker Compose Environment
```yaml
version: '3'

services:
deputy:
image: sayjava/deputy:latest
environment:
DEPUTY_PORT: 8080
ports:
- 8080:8080
```
### Enable HTTPS


<!-- ## Programmatic
Behave can also be used as an express middleware in an existing application.
Expand All @@ -69,5 +101,5 @@ app.use(behaveHandler({ config: { fromFile: 'behaviors.yaml' } }));
// can also be mounted on a path
app.use('/api', behaveHandler({ config: { fromFile: 'api.yaml' } }));
app.listen(3000, () => console.info(`App started on 3000`));
app.listen(3000, () => console.info(`App started on 3000`)); -->
```
2 changes: 1 addition & 1 deletion src/deputy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const args = yargs(hideBin(process.argv))
.option('from-file', {
type: 'string',
alias: 'f',
describe: 'JSON file containing array of behaviors',
describe: '.yml file containing array of mocks',
default: process.env.MOCK_FILE || 'mocks.yaml',
}).argv;

Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/ServerStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiFilled } from '@ant-design/icons';
import { Modal } from 'antd';
import { useServerState } from './Provider';

export const ServerStatus = () => {
Expand All @@ -10,5 +11,5 @@ export const ServerStatus = () => {
return <></>;
}

return <ApiFilled style={{ color: '#ff0000' }} />;
</Modal>
};

0 comments on commit cdf1ac1

Please sign in to comment.