0.2.0 • Published 10 years ago

mocking-bird v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Mocking Bird

Mocking server to work with hybird application, working with proxy server that using express3.x.

Installation

npm install mocking-bird -g

Usage

Used in command line

mkb server [static folder] [-p|--port <server running port>] [-P|--proxy <js file exports express app as proxy|or hostname for directly delegate>]

See more help info by typing mkb -h

Only run as static server with web.js injection:

mkb server .

Run with proxy all missing request to www.target.com:

mkb server . -P www.target.com

Used in code

Create your custom proxy

var mkb = require('mocking-bird');

var baseProxy = mkb.baseProxy;

// create a proxy application

var app = baseProxy('real_server_address:8010', {
  headers: {
    "user-agent": "MockClient 1.1 (proxy 1.6.0 appstore; iPhone 5.1 x86_64)",
  },
  jsonfy: function(data, callback) {
     // if data is "{ code: 200, data: {}}", do transform and jsonfy here
     var json;
     try {
        json = JSON.parse(data);
     } catch(e) {
        return callback(e);
     }

     callback(null, json.data);
  }
});

module.exports = app;

Then you can use proxy.js as proxy provider to the mocking server:

mkb server public -P proxy.js
0.2.0

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.0

10 years ago