0.0.6 • Published 4 years ago
flexmock v0.0.6
FLEXMOCK GUIDE
Install
npm i flexmock -dUseage
mock data
create ./mockdata.json
{
"list|20-50": [
{
"id|+1": 1
}
]
}mock server
create ./mock.js
var run = require('flexmock')
var mockdata = require('./mockdata.json')
run(mockdata)Run
node mock.jsvisit http://localhost:3000
Api Rule
{
"user": [
{
"name": "user1",
"id": "1",
"type": {
"t1": true,
"t2": false
}
},
{"name": "user2", "id": "2", "type": {"t1": true, "t2": false}},
]
}GET /user
GET /user/1
POST /user
POST /user/1
PUT /user/1
PATCH /user/1
DELETE /user/1query
GET /user?id=1
GET /user?type.t1=true
GET /user?id=1&id=2page
GET /user?_page=3
GET /user?_page=3&_limit=5sort
GET /user?_sort=id&_order=asc
GET /user/1?_sort=type&_order=asc
GET /user?_sort=name,id&_order=desc,ascslice
GET /user?_start=20&_end=30
GET /user?_start=20&_limit=10more detail: doc
Mock Rule
date
Random.date()
Random.time()
Random.datetime()
Random.datetime('yyyy-MM-dd A HH:mm:ss')
Random.now('year')
Random.now('month')
Random.now('week')
Random.now('day')
Random.now('hour')
Random.now('minute')
Random.now('second')text
// letter
Random.paragraph()
Random.paragraph( len )
Random.paragraph( min, max )
// chinese
Random.cparagraph()
Random.cparagraph( len )
Random.cparagraph( min, max )name
// random name
Random.first()
Random.last()
Random.name()
// random chinese name
Random.cfirst()
Random.clast()
Random.cname()address
Random.region()
Random.province()
Random.city()
Random.city( true )
Random.county( true )
Random.zip()other
Random.guid()
Random.id()
Random.increment()more detail: doc