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

nei-mock

v2.0.1

Published

NEI based data mock scheme

Downloads

12

Readme

neiMock

NEI based data mock scheme 基于nei的数据mock方案

1. 需要在package.json同级创建一个配置文件neimockConfig.js文件
// neimockConfig.js
const { createNeiMockConfig } = require('./nei-mock');

module.exports = createNeiMockConfig({
    /**
     * nei项目的唯一标识
     * 写法1,唯一的nei项目
     *  key: {String}
     * 写法2,多个nei项目,后续可选择使用哪个项目
     *  key: {
     *      'projet1': {String},
     *      'project2': {String}
     *  }
     */
    key: '07841b89b63b942b1bb0abcfd090685d',
    domain: 'http://localhost:8082', // 数据源服务器,默认https://nei.netease.com
    // 代理到proxyTarget的接口
    proxyURL: ['/api', '/community'],
    proxyTarget: {
        'default': 'http://content.kaola.com',
        'user_test6': 'http://10.206.58.10:5052',
        'stable_master': 'http://10.165.125.185:5052',
        'pre5': 'http://10.201.171.244:5052'
    },
    // 本地mock数据存放目录
    localMockData: 'mock',
    forceUpdate: 're-select' | 'use-current-selection' | false,
    mixedProxy: {
        '/api1': '/api2'
    }
})
2. 使用
用法1:
// webpack
const { neiMock } = require('nei-mock')

devServer: {
    before: function(app) {
        console.log('before start')
        neiMock(app)
    }
}

// vite
import { vitePluginNeiMock } from './nei-mock-vite';

plugins: [
    ...,
    vitePluginNeiMock(),
    ...
]
用法2:
var express = require('express')
var app = express()

var neiMock = require('nei-mock')
neiMock(app)
3. 以上两种用法都是在启动服务的同时使用nei-mock,但是我们有这样的需求:不重启服务、更新本地mock数据。这时候可以直接执行local-mock.js:
// package.json
"scripts": {
    "mock": "node node_modules/nei-mock/local-mock/local-mock.js",
}