rest-stub
v1.0.0
Published
HTTP server which provides stubbed response
Downloads
2
Readme
rest-stub
Simple web application which automatically responds to HTTP requests.
Often when creating applications which consume REST APIs, the resource endpoints don't yet exist or are somehow unavailable. With this application, those requests can be pointed somewhere temporarily and provide real responses without the hassle of writing stubs.
Available Endpoints
/delay/[time]
- A200
response that is delayed by[time]
seconds./echo/[status]
- A response of[status]
status code with no content. Prints request body to the console./status/[status]
- A response of[status]
status code with no content./wildcard/[percentage]
- A response which randomly fails roughly[percentage]
percent of the time./[*]
- Catch-all responder. Will recognize two custom headers:x-delay
- Delays response by given integer.x-status
- Response will return with given status code (1xx - 5xx).
Usage
npm install rest-stub
npm start
The application runs on port 48200
.
On OS X, a launch agent is included (if a little clunky to use):
- Edit the
com.mikattack.rest-stub.plist
file and change the/PATH/TO/server.js
string to point to whererest-stub
was placed. - Copy
com.mikattack.rest-stub.plist
to~/Library/LaunchAgents
. - Run
launchctl load ~/Library/LaunchAgents/com.mikattack.rest-stub.plist
Check the Console application's output if the server doesn't seem accessible.