Git Product home page Git Product logo

mockman's Introduction

Mockman

中文文档

Build Status Build status

Mockman is a powerful and convenient tool that helps you to manage and start mock servers locally.

With the app, you can easily configure the routes, request format and response of a mock server

Screenshot

Mockman Logger

Usage

Feature

  1. Create your mock server - click the add button
  2. Configure the name, port and prefix of your move server, make sure the port is not in use, or Mockman will give you a error notification.
  3. Add some apis for your mock server.
  4. Configure the method, route, response code, latency, required request options and reponse data of each api.
  5. Start the server - click the start button.
  6. After all, you can test your api locally.

Where will your api data be stored?

Your data will be stored as a sqlite file absolutely on your local, the path will be different on different operation system.

  • %APPDATA% for Windows
  • $XDG_CONFIG_HOME or ~/.config for Linux
  • ~/Library/Application Support for macOS

Be attention before you start https server

  • Mockman is using self-signed-certification to create https server
  • Install rootCA on your client and trust it before you send https requests

Todos

Server

  • ipcMain && ipcRender communication
  • dababase support
  • create a new mock
  • update a mock
  • remove a mock
  • query a mock info
  • create an api
  • update an api
  • remove an api
  • query an api info
  • start an express server with a mock config
  • handle errors while starting the server

Client

  • brand header dislay
  • mock sider display
  • mock-detail and api-list display
  • api-detail display
  • create a new mock
  • update a mock
  • remove a mock
  • query a mock info
  • create an api
  • update an api
  • remove an api
  • query an api info
  • request params check list
  • response k-v input group
  • response code editor
  • add blur event to jsonEditor
  • add a log panel to show the logs of an active mock server process
  • add https support
  • group the apis with tag
  • check the conflict of all mocks
  • Export/Import mock or api configurations

License

license

Contribute

# install the dependencies 
npm install

# serve with hot reload at localhost:9080
npm run dev 

# build mockman
npm run build

# run unit tests
npm test 

# lint all JS/Vue component files in `src/`
npm run lint 

mockman's People

Contributors

lancegin 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

mockman's Issues

[Bug] Case-sensitive headers

When you set a header on the Request tab with something like X-Custom-Token and the client requests with a header of either X-Custom-Token or x-custom-token, Mockman will not recognize any of those. Check the postman screenshot below.
Capitalized first letter header
image1
Lower-cased header
image2

As according to the official specs rfc7231

3.2.  Header Fields
   Each header field consists of a case-insensitive field name followed
   by a colon (":"), optional leading whitespace, the field value, and
   optional trailing whitespace.

Therefor, Mockman should accept valid header fields regardless of its letter-case.

Note:
Mockman accepts case-insensitive headers only if the header on the Request is set to all lower-case.

[BUG] Does not allow direct query parameters

Mockman does not allow setting query parameters on the path section. If you add a query parameter, the path does not work.

An example:
Side to side screenshot of Mockman as the mock server and Postman as the client.
Image

Suggestion:

  • Allow user to direct input the query parameters on the path field, and automatically add it on the request's Param section.
  • Also it would be nice to allow user to set a static value for those params and only accept requests if the parameters are the same value.

there are dynamic parameters in the URL of the get method, how to set them?

Question

in our interface definition specification, there can be dynamic parameters in the url of the get request method. Excuse me, in such a scenario, how should I use Mockman to simulat data?

For Example

Method: GET
URL: /files/download/{resourceCode}/{other dynamic params}

Swagger

企业微信截图_20200606070329

the resourceCode in the url is a variable, which is generated according to the front-end user's choice

Bug, suggestions and standards

Bug

  • The response body does not allow text/string responses. It only allows if it is double quoted. So when you put "ok" on the response, the respond will be the same with quotes. It should basically allow anything with or without quotes.

Suggestion

  • Currently the response's default content-type is set to be application/json, I know most apis responds with this type, but is not always the case. Its ok to have this as default, but i suggest that you automatically add/include it on the headers section, so user knows that it is using application/json content-type.
  • Same with the content-type, if you want to set the Access-Control-Allow-Origin to * then add/include it on the headers section so users knows that it is using it.
  • Allow setting a cookie with specific path, domain, expiry and the option httponly, because currently, the cookies are always set to path=/ domain as localhost http false and empty expiry.
  • Do not allow multiple routes with the same path and same method, as this is redundant and your app will always use the first one declared.
  • Add HEAD method.

Standards

  • According to HTTP Methods GET HEAD OPTIONS do not accept body parameters. So do not allow setting of body parameters for those routes.

If you accept PRs I'd be happy to look into some of them. Cheers!

Edit:

  • Would also be nice to remove the X-Powered-By: Express on the response headers

[Feature Request] Dynamic responses, Custom error response Advance Logging

Dynamic responses
I'd like to request additional feature to be able to mock a server and respond dynamically based on parameters.

Excample scenario of this request:

  • I create a mock server running on localhost:3000/api/getinfo with a params of user
  • Then i could add a simple json record where the app could get the info from.
  • Then on response tab, i can put something like { "success": true, "data": $user }
  • The mock server will then get the data part on the given json based on the given params.

Custom error response

  • The current setup is when a params is given and it is missing from the request, it will respond with {"errors":[{"key":"user","details":"required params."}]}
  • It would nice if the user is able to customize this respond on every route.

Advance Logging

  • It would be nice to have something like an advance tab where user can view the actual request that was received. Something similar to this image
    image

Thanks!

Missing eslintrc rule linebreaks for windows platform

Building from source on windows platform (Windows 10 x64), npm run build return this error:
Expected linebreaks to be 'LF' but found 'CRLF'

Adding the following rules to .eslintrc file fix the issue:

'rules': {
	"linebreak-style": 0,
	"eslint linebreak-style": [0,"error","windows"],
...

Clear Logger Button

It would be great to have option to clear Logger view ether through menu or using a button on Logger view.

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.