npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-mock-data

v1.0.3

Published

简易的本地虚拟数据服务

Downloads

6

Readme

Simple Mock Data

简易的本地模拟数据服务,使用方便,基于 mock.js、koa、nodemon 制作,支持 http 协议

目录

安装

npm i simple-mock-data -g

或者

npm i simple-mock-data -d

使用方式

直接使用命令行的方式包装了您的应用程序,因此您可以将通常传递给应用程序的所有参数传递给 例如:

simple-mock-data -p 3002 -d ./example/db -P '' -ls 0

或者在 nodejs 中使用

const simpleMock = require('simple-mock-data')

// prot:端口 dir:数据文件 prefix:路由前缀 listShow:是否显示接口列表
simpleMock(3001, './db', { prefix: '/api', listShow: true });

配置方式

数据文件

指定了数据文件夹后,会自动读取目录下的 js 文件,文件修改会自动重启服务

具体配置方式请参考 example 下的 db 文件

module.exports = {
  // 方法 路由 状态,以单个空格分开
  'post /test 401': {
    msg: 'hello worlds',
    code: 40001,
  },
  'get /test/list': {
    // mock.js 的参数生成方式
    'list|1-100': [
      {
        // 属性 id 是一个自增数,起始值为 1,每次增 1
        'id|+1': 1,
      },
    ],
  },
};

Options

  -v, --version             输出当前的版本号
  -p, --prot [number]       端口号 (default: 3001)
  -d, --dir <string>        路径 (default: "./db")
  -P, --prefix <string>     接口前缀 (default: "/api")
  -ls, --listShow <number>  是否显示接口列表 (default: 1)
  -h, --help                display help for command

推荐使用方式

在 package.json 中设置脚本,同时配合 concurrently 使用效果更佳

"scripts": {
  "start": "concurrently \"npm run dev\" \"npm run mock\"",
  "mock": "simple-mock-data -p 3001 -d ./example/db -P '/api' -ls 1"
},

关于代理方面,请参考:

  • webpack: https://webpack.docschina.org/configuration/dev-server/#devserverproxy
  • vue: https://cli.vuejs.org/zh/config/#devserver