Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@iitrend/mock-server
Advanced tools
Readme
mock-server
接口模拟数据-服务器
const MockServer = require('@iitrend/mock-server')
// 建议在业务代码编译完成之前启动
new MockServer({
mockPort: 8810
})
启动一个 Server 监听接受请求,并交由 @iitrend/mock-server/core
处理并生成模拟数据。
config
// 以下为默认参数
{
// 自动启动服务
autoStart: true,
// server
mockHost: 'localhost',
mockPort: 8810,
// 配置非json文件指向(匹配中的使用使用js加载方式)
mockData: {
'static/static-config': true
},
// 默认为项目根目录下的 => 'mock/src/’
mockDataPath: path.join(process.cwd(), 'mock/src/'),
// 接口请求延迟(取区间随机值)
mockDelays: [0, 300],
// express app headers
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': '*',
'Content-Type': 'application/json;charset=utf-8'
}
// Mock.Random.extend
// mockExtends: {},
// http://localhost:8810/WHActs/Api/index.php/Client/Home/showIndex => 'Client/Home/showIndex'
// parseMockFile: (url = '') => url.replace(/\?\S*/ig, '').split('/').slice(-3).join('/')
}
mock/src/**/*.json
# 例如请求接口:Client/Home/showIndex
文件及目录:mock/src/Client/Home/showIndex.json
{
"user": "@first()",
"nickname": "@cname()",
"realname": "@cname()",
"firm_name": "广州@ctitle(2,5)有限公司",
"dept_name": "@ctitle(2,5)部",
"sex|1-2": 1,
"birthday": "@timestamp()",
"intro": "@ctitle(5,10)",
"area": "@province()",
"target_step_list": [2000, 4000, 6000, 8000, 10000, 12000],
"target_step_n|+1": [2000, 4000, 6000, 8000, 10000, 12000],
"step_n|10000-20000": 10000,
"step_today|10000-20000": 10000,
"cal_n|10000-20000": 10000,
"cal_today|1000-2000": 10000,
"icon": "@imageFix(50x50)",
"firm_icon": "@imageFix(200x100)",
"phone": "@phone()",
"addr": {
"id|+1": 1,
"name": "@cname()",
"addr": "@province()@city()@county()@ctitle(1,3)街@integer(1,2000)号",
"phone": "@phone()"
},
"weight|50000-100000": 70000,
"height|100-240": 1
}
FAQs
IITrend Mock Server.
The npm package @iitrend/mock-server receives a total of 0 weekly downloads. As such, @iitrend/mock-server popularity was classified as not popular.
We found that @iitrend/mock-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.