1.0.4 • Published 5 years ago

yet-another-fake-server v1.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

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-server

Start the server:

$ yarn run yafs

Server options:

ParamDescriptionDefaultPossible value
--portWhich port should the server listen9000Any unused port
--corsShould the server handle cors?falseBoolean
--proxyIf a request is not defined, proxy it to another domainAny domain
--finThe file to load the saved requestsAny file
--foutThe file to save the requestsAny file

Example:

$ yarn run yafs --port 9001 --cors --proxy localhost:3000 --fin requests.in.json --fout requests.out.json

Add 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/clear

Usage

Add new path:

ParamDescriptionRequiredDefaultPossible value
methodHTTP method that you wantNoGETGET, POST, etc.
pathThe path that you want to addYes/admin, /greeting/me, etc.
statusHTTP status to returnNo200Any valid HTTP status
headersThe headers of the responseNo{}{ "Content-Type": "application/json" } for example
bodyThe expected response's bodyNoAny 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

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

0.2.0

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago