0.0.5 • Published 4 years ago

tomock-tool v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

tomock-tool

A simple tool of generating mock api, built by koa.

Install

npm i tomock-tool -g

Usage

tomock --root . --config ./config.js

Configuration

// ./config.js
module.exports = {
  port: 8080,
  headers: {
    'test-header-key': 'test-header-value'
  },
  cookies: {
    'test-cookie-key': 'test-cookie-value'
  },
  routes: {
    '/api/test': {
      get: '/test/test.get.js'
    },
    '/api/test_json': {
      get: '/test/test.get.json'
    },
    '/api/test_fn': {
      get: '/test/test.fn.get.js'
    }
  }
};
// ./test/test.get.js
module.exports = {
  file: 'test.get.js'
};
// ./test/test.get.json
{
  "file": "test.get.json"
}
// ./test/test.fn.get.js
module.exports = async function(ctx) {
  ctx.body = {
    file: 'test.fn.get.js'
  };
};