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

@lissome/mock

v1.0.2

Published

A mock server for front-end development

Readme

Lissome Mock

前端本地mock工具

安装与更新

# 安装
pnpm add @lissome/mock -D

在项目的package.json的对应的npm脚本(npm script):

{
  "name": "mock-demo",
  "scripts": {
    "server": "mock" // 脚本可修改,可增加自定义参数,例如:mock -p 9090 -d ./mock --sleep 200
  },
}

启动mock服务

运行上面添加的npm脚本,启动mock服务

pnpm server

参数说明

参数 | 默认值 | 说明 -----------|:--------:|---------------------------------------: -p, --port | 9090 | 启动端口号 -d, --dir | ./mock | mock数据路径,可以是相对路径也可以是绝对路径 --sleep | 0 | 是否延迟一段时间再返回数据,单位毫秒

mock数据目录说明

约定目录下的index.js文件为配置文件,不能在该文件里写mock数据

mock数据只能是json格式,后缀名没有要求,统一采用readFileJSON.parse来解析数据

数据目录中支持多个文件,也支持文件夹,会一次递归遍历各个文件夹中的所有文件,将所有的mock数据统一在一个routerMap里,因此当存在相同的路由时会报错

mock数据格式说明

mock数据格式如下,具体可见examples文件夹

{
    "api/lego.Web/GetStandardPricings": {
        "code": 0,
            "data": {
            "items|20": [
                {
                    "description": "111",
                    "expected_publish_time": 57600,
                    "id": 4,
                    "model_id": 0,
                    "model_id_name": "对客定价模型0",
                    "progress": 3,
                    "progress_name": "审批通过",
                    "progress_update_time": 1554197687,
                    "user_name": "wwwww",
                    "uuid": "DK201904021709405180"
                }
            ],
            "pagination": {
                "current_page": 1,
                "page_count": 1,
                "page_size": 20,
                "total": 8
            }
        }
    },
    "api/lego.Web/ExportStandardPricingData": {
        "code": 0,
        "data": {
            "file_name": "DK_CW201904259672.xlsx",
            "file_url": "http://finance.lego.web.s3.dns.guazi.com/DK_CW201904259672.xlsx?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=RLZPZYN9BEGZZMAWABPY%2F20190425%2Fus-east-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20190425T095238Z\u0026X-Amz-Expires=300\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=717db3d647038aff8854c91fab0c933002a5b117ca9728f422995d330979d0f5"
        }
    }
}

mock数据配置说明

可同时在根目录和子目录下配置,最终配置为子目录合并根目录,prefix除外

module.exports = {
    prefix: '/sub',  //接口前缀,子目录支持与根目录组合,例如根目录 /api, 子目录'./lego.Web', data.json的key为GetStandardPricings,最终路由为'/api/lego.Web/GetStandardPricings',子目录为绝对路径时(例如/api2/lego.Web),以子目录为准
    getData: data => ({  //返回data时,对data进行嵌套处理的函数,可以省去每个接口都需要写相似结构的麻烦
        code: 0,
        message: 'ok',
        data
    }),
    filter: /data.js/   //只读取目录下复合过滤正则的文件
}