webservice-simulator

1.5.3 • Public • Published

webservice-simulator

NPM version

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

Clone webservice-simulator

git clone git@github.com:leftstick/webservice-simulator.git

install dependencies

cd webservice-simulator
npm 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, for get http method
  • /askfordata, for websocket interreaction
  • /2.jpg, to access the static file

Make your client send those request. And see the response.

LICENSE

MIT License

Readme

Keywords

Package Sidebar

Install

npm i webservice-simulator

Weekly Downloads

0

Version

1.5.3

License

MIT

Last publish

Collaborators

  • howard.zuo