Coder Social home page Coder Social logo

mockserver's Introduction

mockserver

This a demo of mock server built with https://github.com/dreamhead/moco

A standlone mockserver with some basic demo api already built-in.

How to run the mock server

./start.sh

Built-in APIs

4 APIs are built-in this demo. You can add more to match your business value.

  • Login
  • getProfile
  • getNews
  • getNews with ID

You can use Postman to trigger the mock server.

Login

post http://127.0.0.1:12306/user/login

body:
{
    "username": "valid",
    "password": "valid"
}

Response 200 should be get:

{
    "auth": {
        "id-token": "123456",
        "access-token": "98908989089",
        "refresh-token": "34545234234"
    }
}

Please try to post some wrong username & password value to mock server. What you would get?

getProfile

get http://127.0.0.1:12306/user/profile

header:
   "id-token": "123456",
   "access-token": "98908989089"

Response 200 should be get:

{
    "profile": {
        "name": "John Smith",
        "gender": "male",
        "avartar": ""
    }
}

getNews

get http://127.0.0.1:12306/news

header:
   "id-token": "123456",
   "access-token": "98908989089"

Response 200 should be get:

{
    "timestamp": 123123123,
    "news": [
        {
            "id": "123",
            "title": "Tomorrow would rain",
            "subtitle": "Tomorrow would rainTomorrow would rainTomorrow would rainTomorrow would rain"
        },
        ...
    ]
}

If neither id-token | access-token is given with right value. 400 should be returned.

getNews With ID

ID doesn't have to to 123, can be any string.

get http://127.0.0.1:12306/news/123

header:
   "id-token": "123456",
   "access-token": "98908989089"

Response 200 should be get:

{
    "content": {
        "id": "123",
        "header": "",
        "content": {}
    }
}

mockserver's People

Contributors

liluo-tw avatar

Watchers

 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.