1.0.4 • Published 7 years ago
yet-another-fake-server v1.0.4
Yet another fake server
This little package support stubbing HTTP requests. I am trying to make it support any kind of them.
Example
Install:
$ yarn add --dev yet-another-fake-serverStart the server:
$ yarn run yafsServer options:
| Param | Description | Default | Possible value |
|---|---|---|---|
| --port | Which port should the server listen | 9000 | Any unused port |
| --cors | Should the server handle cors? | false | Boolean |
| --proxy | If a request is not defined, proxy it to another domain | Any domain | |
| --fin | The file to load the saved requests | Any file | |
| --fout | The file to save the requests | Any file |
Example:
$ yarn run yafs --port 9001 --cors --proxy localhost:3000 --fin requests.in.json --fout requests.out.jsonAdd new path:
$ curl -XPOST -H "Content-Type: application/json" localhost:9000/_c/add -d '{"path":"/greeting","body":"Hello, world!"}'Visit that new path:
$ curl localhost:9000/greeting
Hello, world!Clear all paths:
$ curl -XPOST localhost:9000/_c/clearUsage
Add new path:
| Param | Description | Required | Default | Possible value |
|---|---|---|---|---|
| method | HTTP method that you want | No | GET | GET, POST, etc. |
| path | The path that you want to add | Yes | /admin, /greeting/me, etc. | |
| status | HTTP status to return | No | 200 | Any valid HTTP status |
| headers | The headers of the response | No | {} | { "Content-Type": "application/json" } for example |
| body | The expected response's body | No | Any string |
TODO
- Release notes
Contribution
- Please feel free to open issues and pull requests, as well as to start discussions. Your contribution is welcome!
License
MIT