# data-mock-server

> mock data server

Latest version **1.0.7** (published 2018-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install data-mock-server
pnpm add data-mock-server
yarn add data-mock-server
bun add data-mock-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-05-03 |
| First published | 2018-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | lujunhao |
| Maintainers | lujunao |
| Keywords | mock, server |

## Links

- npm: https://www.npmjs.com/package/data-mock-server
- Repository: https://github.com/jonhal/data-mock-server
- Homepage: https://github.com/jonhal/data-mock-server#readme
- Issues: https://github.com/jonhal/data-mock-server/issues
- npm.io page: https://npm.io/package/data-mock-server

## Dependencies (6)

- [cors](https://npm.io/package/cors.md) ^2.8.4
- [react](https://npm.io/package/react.md) ^16.2.0
- [express](https://npm.io/package/express.md) ^4.14.0
- [firebase](https://npm.io/package/firebase.md) ^4.12.1
- [react-dom](https://npm.io/package/react-dom.md) ^16.2.0
- [promise-fs](https://npm.io/package/promise-fs.md) ^1.3.0

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@toad-contracts/testing](https://npm.io/package/@toad-contracts/testing.md) — 0 weekly downloads
- [@bcc-code/db_masker](https://npm.io/package/@bcc-code/db_masker.md) — 0 weekly downloads
- [mocksimple](https://npm.io/package/mocksimple.md) — 0 weekly downloads

## Recent versions

- 1.0.7 (latest) — 2018-05-03
- 1.0.6 — 2018-04-27
- 1.0.5 — 2018-04-19
- 1.0.3 — 2018-04-19
- 1.0.2 — 2018-04-16
- 1.0.1 — 2018-04-11
- 1.0.0 — 2018-04-11

## README

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]()   [![NPM version](https://badge.fury.io/js/data-mock-server.svg)](https://npmjs.org/package/data-mock-server) 

# data-mock-server  - 接口模拟服务平台

配合 [data-mock-send](https://github.com/jonhal/data-mock-send) 使用效果更佳

## 功能特性

#### 强大功能
1. 自建数据模拟服务器 -- 一键搭建数据模拟接口服务平台
2. 极速开发模拟 -- 直接curl或者使用postman发送post请求即可配置模拟请求
3. 项目本地数据模拟 -- 搭配data-mock-send模块，一键配置本地数据模拟文件
4. 临时调试模式 -- 提供云服务器可最直接在线调试

### 建议使用场景
1. 本地开发调试中，将mock数据文件放到项目文件中配合data-mock-send模块，实现异步请求的模拟
2. 本地开发调试中，将mock数据直接post到云服务器中进行配置模拟开发

### 如何使用？
1. npm install data-mock-server
2. 安装mongodb
3. 配置config.js文件，如果服务端口号和数据库端口号没有占用的话，用默认的即可
4. 启动服务
```javascript
npm run start
```
5. 配置mock数据，服务器地址后面需要加initdataformock，标识新增数据。使用postman等其他也可以

  curl -XPOST -H "Content-type: application/json" -d '{
  "name": "lujunhao",
  "age": 11
}' 'http://127.0.0.1:3000/e0ec6057dafaaadd0ca9fa87a73d5e64ba881891e7e3d2af3a7f1ae228e5410j/initdataformock/aa/bb' 

6. 获取mock数据，根据配置的url，会返回数据，支持get和post请求

  curl -XPOST -H "Content-type: application/json" -d '{
  "name": "lujunhao",
  "age": 11
}' 'http://127.0.0.1:3000/e0ec6057dafaaadd0ca9fa87a73d5e64ba881891e7e3d2af3a7f1ae228e5410j/aa/bb' 

7. 服务启动之后可参考demo https://github.com/jonhal/data-mock-demo

### config文件配置
 1. serverPort -- 服务端口号 【默认即可】
 2. dataBaseUrl -- mongodb的服务器地址【默认即可】 
 3. dataBaseName -- mock数据库名称 【默认即可】
 
### 我们还想做的
 1. 提供云服务端的数据模拟，不需要配置直接请求线上服务器
 2. 接口文档转换，根据文档格式自动配置mockmock数据
 3. 欢迎issue 或者发邮件simotophs@gmail.com

---
_Source: https://npm.io/package/data-mock-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
