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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fe-data-mock

v1.0.14

Published

data-mock

Downloads

7

Readme

fe-data-mock 前端数据模拟服务

功能列表

  • 支持多种请求类型 (get,post,put, delete),返回不同数据;

  • 支持Mockjs模版解析

  • 模拟请求延迟

  • 模拟请求失败

  • 界面添加json数据,生产对应json文件

  • 便捷复制创建数据功能

  • 数据修改,增加 界面编辑操作,同步修改json文件

  • 对接校验组件 校验差异处理(界面操作更新mock数据和后端服务一致)

to do

  • 接受特定参数,返回对应处理 mockType=(false,ok)

依赖组件

. koa
. Mockjs
. chokidar 可以用于监控文件、文件夹变化,并可以简单实现递归目录监控。
. yargs模块提供了argv对象,用来读取命令行参数

本地开发

  1. npm install
  2. npm run dev

使用方式 (npm)

  • npm install -D fe-data-mock
  • package.json 中配置:
 "scripts": {
    "mock": "feMock --dir=mock --port=8989",
    "dev": "npm run mock & webpack-dev-server --mode development --progress --hot --config webpack.config.js",
  }
  • webpack.config.js 中配置
    // 服务配置
    devServer: {
        contentBase: path.join(__dirname, 'dist'),
        host: '127.0.0.1',
        port: 3000,
        proxy: {
            '/api': {
                target: "http://127.0.0.1:8989",
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''
                }
            }
        },
    },
  • 注意端口8989两边保持一致。
  • 根据上面配置,在项目中添加mock的目录, 把数据模拟以json文件方式添加到mock目录中。
  • 注意url与mock 的目录及文件之间的对于关系:

举例: 请求接口: /api/usr/list 对于 mock数据 在usr文件夹中list.json中

联系我们

如遇到使用问题,或是有其他功能需求,可以联系我们。QQ群:28861454,加时备注"fe-data-mock"。

QQjishuQun