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

ma-mock

v1.1.0

Published

用于mock和proxy的服务器

Downloads

4

Readme

ma-mock

npm

用于mock和proxy的服务器,可以某些api使用proxy某些api使用mock数据

Installation

npm install --save-dev ma-mock

Usage

创建.mamockrc.js文件

const path = require('path');

// 默认配置
module.exports = {
  prefix: '/__DEV__',
  rootPath: path.resolve(__dirname, './data/mock'),
  proxyPath: path.resolve(__dirname, './data/proxy'),
  proxyFilename: 'config.json',
};

webpack配置proxyTable

// ...省略
module.exports = {
  // ...省略
  dev: {
    // ...省略
    proxyTable: {
      // 填写 .mamockrc.js的prefix,默认为'/__DEV__'
      '/__DEV__': {
        target: 'http://localhost:3001', // 接口的域名
        // secure: false,  // 如果是https接口,需要配置这个参数
        changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
      }
    },
  },
}

运行命令

mamock [--port 3001]

Dev

# Installation
npm install

# dev
npm run dev

# build
npm run build

# start
npm run start

# format code style
npm run format

Update

v0.1.0

server端已完成,mock数据与proxy config写在./server/data内,因没有使用redis,所以./server/lib/Global维护一份全局变量

v0.2.0

client端完成

v0.2.1

添加precommit,进行prettier格式化和client端eslint检查

v1.0.0

可以通过mamock命令启动,自动读取配置文件,前端展示readme

v1.0.1

增加example

v1.0.2

更新example配置

v1.1.0

新增:mock配置添加path-to-regex判断,可创建/:xx/xxxmock接口 修复:_init()函数执行顺序 修复:spaStatic插件的matchReg参数配置,该问题导致其他url会匹配静态资源