Git Product home page Git Product logo

easy-mock-cli's Introduction

Node.js Version MongoDB Version Redis Version Build Status Coverage Status js-standard-style License Chat

Thanks to Souche Inc. which provides the server to hold an online service.

Souche Inc.

Links

Introduction

If you're unable to deploy an Easy Mock service by yourself, the online service is recommended.

Easy Mock is a persistent service that generates mock data quickly and provids visualization view.

Features

  • Support API proxying
  • Convenient shortcuts
  • Support Collaborative editing
  • Support team project
  • Support RESTful
  • Support Swagger | OpenAPI Specification (1.2 & 2.0 & 3.0)
    • Create project quickly based on Swagger
    • Support displaying parameters and the return value
    • Support displaying class model
  • More flexible and extensible in response data
  • Support for custom response configuration (example: status/headers/cookies)
  • Use Mock.js schema
  • Support restc to preview API

Quick Start

Before starting, we assume that you're already have installed Node.js (v8.x, v10.x is not supported) & MongoDB (>= v3.4) & Redis>= v4.0).

Installation

$ git clone https://github.com/easy-mock/easy-mock.git
$ cd easy-mock && npm install

Configuration

Find config/default.json or create config/local.json to overwrite some configuration.

Easy Mock will load different configuration files according to your environment. Reference to node-config to get more information because Easy Mock uses node-config as its configuration module.

{
  "port": 7300,
  "host": "0.0.0.0",
  "pageSize": 30,
  "proxy": false,
  "db": "mongodb://localhost/easy-mock",
  "unsplashClientId": "",
  "redis": {
    "keyPrefix": "[Easy Mock]",
    "port": 6379,
    "host": "localhost",
    "password": "",
    "db": 0
  },
  "blackList": {
    "projects": [], // projectId, e.g."5a4495e16ef711102113e500"
    "ips": [] // ip, e.g. "127.0.0.1"
  },
  "rateLimit": { // https://github.com/koajs/ratelimit
    "max": 1000,
    "duration": 1000
  },
  "jwt": {
    "expire": "14 days",
    "secret": "shared-secret"
  },
  "upload": {
    "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
    "size": 5242880,
    "dir": "../public/upload",
    "expire": {
      "types": [".json", ".yml", ".yaml"],
      "day": -1
    }
  },
  "ldap": {
    "server": "", // Set server to enable LDAP login. e.g. "ldap://localhost:389" or "ldaps://localhost:389"(use SSL)
    "bindDN": "", // Username,e.g. "cn=admin,dc=example,dc=com"
    "password": "",
    "filter": {
      "base": "", // Base where we can search for users,e.g. "dc=example,dc=com"
      "attributeName": "" // e.g. "mail" or "email" etc.
    }
  },
  "fe": {
    "copyright": "",
    "storageNamespace": "easy-mock_",
    "timeout": 25000,
    "publicPath": "/dist/"
  }
}

Note:

  • The default value of publicPath is '/dist/'. You can replace it to your own CDN if necessary.
  • If you changed some configuration of fe, you should run build command to adapt that changes.

Background:

Easy Mock supports two background service, Unsplash and Bing.

If you leave unsplashClientId blank, the background will be provided by Bing.

Launch

$ npm run dev
# Visit http://127.0.0.1:7300

More Commands

# Build front-end assets
$ npm run build

# Run Easy Mock as production environment (You should run `build` first)
$ npm run start

# Run unit test
$ npm run test

# Test lint
$ npm run lint

Deployment

Please configure your configuration files before this step.

PM2

We're recommending you to use PM2 as your daemon process.

Install PM2 Globally

$ [sudo] npm install pm2 -g

Launch via PM2

You should run build before this step.

$ NODE_ENV=production pm2 start app.js

Releases

Refer to Release and you'll get all the releases and theirs changelog.

Contributing

Easy Mock is now maintained by Mobi-Architecture team of Souche Inc. If you have any question about this project, you're welcome to post Issues or make some Pull Requests. Before contributing, we think you'd better read the contributing guide.

Real-Time Feedback

You may make some real-time feedback via QQ group.

QQ is the most popular IM software in China and you can get it downloaded via http://en.qq.com/.

The QQ group number is 595325417, and here's the QR code of the group:

Who Deployed Easy Mock

If you deployed Easy Mock in your own server, please tell us

Core Contributors


chuangker

XadillaX

ostoc

xinyu198736

License

GPL-3.0

easy-mock-cli's People

Contributors

chuangker avatar muwoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easy-mock-cli's Issues

easymock init时报错

easy-mock-cli unable to get local issuer certificate,请问是什么原因导致的?还是说需要配置什么?

projects配置项, 当id重复时, 可否都生成, 而不是只生成第一个

自动生成api时, 都生成在一个文件中了, 而实际开发时, 可能会按照业务分开多个api的js文件, 那么我看projects配置项可以配置多个, 我就在想, 可以用white来控制生成各种业务的api文件, 例如
"projects": [
{
"id": "5c64f9e9fbee5808a30312bc",
"name": "auth",
"white": [
"/auth"
]
},
{
"id": "5c64f9e9fbee5808a30312bc",
"name": "plat",
"white": [
"/plat"
]
}
]
但是发现, 这样配置, 只生成了auth, 并没有生成plat, 那更麻烦点可以解决这个问题, 我就需要创建多个个人项目, 关联同样的swagger, 这样配置项里的id就可以不同了, 但是这样解决显然特别麻烦, 想想, 一个项目如果有10个业务, 那么需要在easymock上创建10个冗余的项目, 为了获得不同的id.

能否请大神稍做修改, 支持projects里配置相同的id.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.