FAKER-MOCK
A simple mock server build with Mock.js and Faker.js
Usage
Install
$ npm i faker-mock --save-dev
Example
use middleware with express
const app = const config = path: '/user/:id' method: 'get' delay: 1000 status: 200 data: count: 10 'result|10': id: '@fake(uuid)' // use method of faker.js month: '@fake(date.month)' name: '@cname' // or use method of mockjs itself ...appapp
or start a server directly
use a file path as config
// config.jsmoduleexports = path: '/user/:id' delay: 1000 data: count: 10 'result|10': id: '@fake(uuid)' name: '@fake(findName)' ...// server.jsconst filePath = path...app// or
send a request
curl 'localhost:3000/user/123' wait 1000ms ...output: