webservice-simulator
Webservice-simulator is simple use module, by which you can build up your backend webservice quickly without any help from the backend team/developer.
Story
As a front-end developer, have you ever had the experience of asking back-end developer to provide a worked web-service even a mock, just for not blocking your task. But they ignore your request?
That's why i wrote the webservice-simulator
.
Installation
npm install webservice-simulator --save-dev
Usage
var path = require('path');var Simulator = require('webservice-simulator'); new Simulator({ port: 9900, routerDir: path.resolve(__dirname, 'routers')}).start();
By doing as above, you've launched an http server:
- Listening on
9900
- Serve route configurations from
path.resolve(__dirname, 'routers')
API
Simulator(options)
options
Type: Object
Options to pass to new Simulator
options.port
Type: Number
Default: 3000
The port of the server which you want to listen.
options.routerDir
Type: String
Default: ./routers
The route configurations directory from where webservice-simulator
read config files and configure the server.
How to write route configuration file
Play with example
webservice-simulator
Clone git clone git@github.com:leftstick/webservice-simulator.git
install dependencies
cd webservice-simulatornpm install
you may want to use a more efficient by sero-cli
launch example
example/example.js
play
Now, you have the simulator setup. which provides following apis:
/hello
, forget
http method/askfordata
, forwebsocket
interreaction/2.jpg
, to access the static file
Make your client send those request. And see the response.