Code Monkey home page Code Monkey logo

amock's Introduction

AMock README

It's a lightweight mock server plugin based on express. No more than 5 minutes of skilled use. It's useful when you develop frontend applications with VS Code github. Document δΈ­ζ–‡

Features

  • Start AMock Server
  • Reload AMock Server
  • Stop AMock Server
  • Config AMock Unit
  • Config AMock Server

Usage

  • Install Amock Server*: Search amock in vscode exstention exploer and install it.
  • Config AMock Server: When you open workspace ,this plugin while create a default .amock floder and ./amock/setting.json in your workspace. Setting.json is the server config, you can modify it to adapt your requirements.
  • Config AMock Unit: You can add amock unit config in ./amock floder. Amock unit config file name must like *.amock.js.
  • Run AMock Server: To start AMock Server. In Explorer of VS Code,click "AMock" in the bottom left corner, then click the start button to run amock server.When start success, you can use it in your frontend project or test it with browser or postman.
  • Reload Amock Server: When you modify and save settings.json or *.amock.js files. in Explorer of VS Code in the bottom left corner , then click the reload button to reload config

Setting

  • settgin.json:

    {
        name:"servername",
        port:3000 // default port 3000
    }
    
  • *.amock.js: .amock.js config like this

        amock(unit| unit[], options?)
    

    amock(unit) Example

    amock(unit[],options) Example

    amock unit prop description

    prop type desc required
    path string The request path true
    method string Suported 'all','delete','get','put','post'. Default 'all' false
    response object This is the default res when there are no filter true
    filter function If need return different res with different request can use this filter, it has two param and should return a new response. false
    amock({
        path:"/hello",
        response:{
            code:1,
            msg:"success",
            data:{
                hello: "amock"
            }
        },
        filter:function(request,response){
            return response;
        }
    })
    
  • amock unit.path : AMock Server is based on express 4. The path have all features express.4 path supported.

  • amock unit.filter: Filter is a call back function before server send response. The request param have all props express.4-request supported.

  • options: You can set common reponse format, url perfixed with options.

options prop examples

prop type desc required
fileNameAsPathPerfix boolean If set true, current amock config name will be urlprefix. default is false false
urlPrefix string set a editable url prefix false
commonResHandler object when you set this prop,response will hanbled by this handle false

commonResHandler prop examples

prop type desc required
handle string it must be set when you use commHandler,this value will be prop container amock unit response true
* any you can set anything you common repsone should have false

Issues

Currently, the extension is in the very initial phase. If you find any bug or have any suggestion/feature request, please submit the issues to the GitHub Repo. Or you can send email to [email protected].

amock's People

Contributors

gamedilong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.