New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dx-mock

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dx-mock

dx mock工具,将`/data`、`/data.json`格式的api请求映射到本地的`.js`或者`.json`文件

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

dx-mock

dx mock工具,将/data/data.json格式的api请求映射到本地的.js或者.json文件

使用方式

const dxMock = require('dx-mock)

// 在webpack的配置上加入
devServer: {
  before (app) {
    dxMock(app, { root: path.join(__dirname, 'api') })
  }
}

接下来在请求/data/data.json时,会依次查找root目录下的.js.json文件,json文件直接返回数据即可,js文件的使用格式是

module.exports = function(req, res) {
  return {
    "success": true,
    "data": "data"
  }
}

参见api目录下的示例

优点

  • 使用简单
  • 直接基于webpack-dev-server底层的express,能满足大部分使用场景
  • 自动清除root目录下的node require缓存

FAQs

Package last updated on 04 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc