1.2.0 • Published 9 years ago

node-mocker v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

Mocker

NPM License Downloads

A proxy-pass server to mock backend data automatically.

Usage

const koa = require('koa');
const mocker = require('node-mocker');

const app = koa();
app.use(mocker({
  dir: 'mock-data',
  mode: false, // false | {save: false, mock: false}
  backends: [{
    prefix: '/api',
    backend_prefix: '/awesome',
    host: 'http://awesome.backend.com',
  }],
}));

Modes

config.mode is either false or an object with attributes below:

  • mock: Boolean

    Try to load responses from cache, and send requests when no cache data is found.

  • save: Boolean

    Fetch from remote and save the successful responses to cache directory (config.dir).

Backends

Backends should be an array of objects with attributes below:

  • prefix: Required

    The prefix to match URLs that should be by-passed to proxy.

  • host: Required

    The target host of proxy.

  • backend_prefix: Optional

    If other than null, the prefix in request.url will be replaced to backend_prefix.

1.2.0

9 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago