Skip to content

gortin-x/uni-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uni-mock

APM

NPM

data mock service for developer

Installation

npm install uni-mock -save-dev

Run

uni-mock

Config

touch a config file named um.config.js to set your own mock service

  • path Set the listening directory according to the project
  • suffix Set the service server path suffix
  • host Set the service server host
  • port Set the service server port

Example

um.config.js

module.exports = {
    path: "/mock",
    suffix: "_MOCK_",
    host: "localhost",
    port: 8080
}

mock.json

{
    "reponseCode": "0000",
    "reponseData": {
        "name": "Tom"
    }
}

mock.js

module.exports = function (params){
    if(params.name === 'Tom'){
        return{
            "reponseCode": "0000",
            "reponseData": {
                "name": "Tom"
            } 
        }
    }else{
        return{
            "reponseCode": "9999",
            "reponseData": "invalid user name!"
        }
    }
    
}

About

data mock service for developer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published