项目作者: jaycverg

项目描述 :
Express Mock API Server
高级语言: JavaScript
项目地址: git://github.com/jaycverg/express-mock-server.git
创建时间: 2019-10-17T00:27:46Z
项目社区:https://github.com/jaycverg/express-mock-server

开源协议:MIT License

下载


Simple Express Api Mock Server

Adding Routes

  • create a new json file under routes directory (just follow the sample json files in the repo)
  • start the server using npm start

Route Sample File

  1. Responds to http://localhost:9090/api2 and returns {"default": "message"}.

    1. {
    2. "path": "/api2",
    3. "port": 9090,
    4. "response": {
    5. "default": "message"
    6. }
    7. }
  2. Responds to the following:

    • http://localhost:5050/dashboard/stats?type=1 and returns {"someKey": "someValue"}
    • http://localhost:5050/dashboard/stats?type=2 and returns {"someKey": "someOtherValue"}
    • http://localhost:5050/dashboard/stats and returns {"default": "message"}
      1. {
      2. "path": "/dashboard/stats",
      3. "port": 5050,
      4. "queries": [
      5. {
      6. "params": {"type": "1"},
      7. "response": {
      8. "someKey": "someValue"
      9. }
      10. },
      11. {
      12. "params": {"type": "2"},
      13. "response": {
      14. "someKey": "someOtherValue"
      15. }
      16. }
      17. ],
      18. "response": {
      19. "default": "message"
      20. }
      21. }

Repository Forks

If you guys fork this project for improvements, please do send me a merge request so that this sample project is also updated for the benefit of other devs.