0.1.8 • Published 6 years ago

kakashi.js v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Kakashi.js

A tool to fake data quickly, easy to config & dead simple

Install

$ npm install kakashi.js -g

Start up

put ‘kakashi.mock.js’ under the root dir of you project

module.exports = {
  'GET /api/hello': {
    hello: 'world'
  },
	'POST /api/foo': {
	  foo: 'bar'
	}
}

then run kakashi in the command-line

$ kakashi

Options

// use kakashi --help to check the options
--port - config which port kakashi should listen to, default is 8008

--config - specfic you own config file path
--delay - fake network delay of requests, random: --delay=100-200, constant: --delay=100
--watch - kakashi will watch default config file and reload server, if you want to add extra file or dir to watch, use this option

Work with Mock.js

const Mock = require('mockjs')

let list = Mock.mock({
    "questions|13": [
        {
            "id|+1": 1,
            "sort|+1": 1,
            "status": 102
        }
    ]
})

module.exports = {
  'GET /api/hello': list
}

Use Express Middleware

module.exports = {
  'GET /api/hello': function(req, res) {
    let { id } = req.body
    res.jsonp({
      id,
      message: 'hello, world'
    })
  }
}
0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago