https://github.com/geminate/easy-mock-server
A mock server for json and mock template files
https://github.com/geminate/easy-mock-server
json mock-server mockjs npm-package
Last synced: about 1 year ago
JSON representation
A mock server for json and mock template files
- Host: GitHub
- URL: https://github.com/geminate/easy-mock-server
- Owner: geminate
- License: mit
- Created: 2018-05-07T03:50:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-16T01:54:35.000Z (over 7 years ago)
- Last Synced: 2025-03-26T01:51:07.363Z (about 1 year ago)
- Topics: json, mock-server, mockjs, npm-package
- Language: JavaScript
- Size: 23.4 KB
- Stars: 22
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://github.com/badges/stability-badges)
# Introduction
EasyMockServer is a mock server for json and mock template files.It can map you json/mockJs file to RESTful url easily.
[](https://nodei.co/npm/easy-mock-server/)
# Install
You can install easy-mock-server as local package
```
$ npm install easy-mock-server
```
or global package
```
$ npm install -g easy-mock-server
```
# Usage
### Basic
```
$ easyMockServer
```
If you mock file tree like this
```
│
├─mock
│ │ basic.json
│ │
│ ├─auth
│ │ login.json
│ │ logout.json
│ │ user.template
│ │
│ └─goods
│ beverage.json
```
The mapping will be
```
./mock/basic.json --> http://localhost:8124/mock/basic
./mock/auth/login.json --> http://localhost:8124/mock/auth/login
./mock/auth/logout.json --> http://localhost:8124/mock/auth/logout
./mock/auth/user.template --> http://localhost:8124/mock/auth/user
./mock/goods/basic.json --> http://localhost:8124/mock/goods/basic
```
* The json file will be returned directly.
* The template file will be translated by mockJs before return. See [mockJs document](http://mockjs.com/examples.html)
* Other file will be ignored.
### Change port
```
$ easyMockServer -p 8088
$ easyMockServer --port 8088
```
### change base path
```
$ easyMockServer -b ./mock
$ easyMockServer --basePath ./mock
```
### set lag
```
$ easyMockServer -l 4000
$ easyMockServer --lag 4000
```