🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ms-mock-cli

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ms-mock-cli

CLI tool to start up a ms-mock mock server for REST API.

1.1.0
latest
Source
npm
Version published
Weekly downloads
78
34.48%
Maintainers
1
Weekly downloads
 
Created
Source

ms-mock-cli

CLI package of ms-mock-core. It provides CLI to start up a mock server given an JSON configuration file.

Installation

npm install -g ms-mock-cli

OR

yarn global add ms-mock-cli

Usage

ms-mock -f <path-to-your-config>.json

Configuration

Please refer to ServerOption in ms-mock-core README

Sample Config JSON

{
  "port": 5020,
  "config": [
    {
      "type": "static",
      "path": "/absolute/path/to/directory"
    },
    {
      "type": "static",
      "path": "./relative/path/to/directory"
    },
    {
      "type": "proxy",
      "path": "/proxied-path",
      "host": "https://www.example.com"
    },
    {
      "type": "combinations",
      "path": "/file/relative",
      "method": "get",
      "combinations": [
        {
          "response": {
            "headers": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ],
            "fileContent": true,
            "filePath": "./relative/path/to/file.json",
            "statusCode": 200
          }
        }
      ]
    },
    {
      "type": "combinations",
      "path": "/file/absolute",
      "method": "get",
      "combinations": [
        {
          "response": {
            "headers": [
              {
                "name": "Content-Type",
                "value": "text/plain"
              }
            ],
            "fileContent": true,
            "filePath": "/absolute/path/to/file.txt",
            "statusCode": 200
          }
        }
      ]
    },
    {
      "type": "combinations",
      "path": "/api/path/1",
      "method": "options",
      "combinations": [
        {
          "cors": true,
          "response": {
            "headers": [
              {
                "name": "access-control-allow-credentials",
                "value": "true"
              },
              {
                "name": "access-control-allow-headers",
                "value": "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization"
              },
              {
                "name": "access-control-allow-methods",
                "value": "DELETE, GET, POST, OPTIONS"
              },
              {
                "name": "access-control-allow-origin",
                "value": "*"
              }
            ],
            "statusCode": 204
          }
        }
      ]
    },
    {
      "type": "combinations",
      "path": "/api/path/1",
      "method": "get",
      "combinations": [
        {
          "cors": true,
          "query": [
                    {
                        "name": "param1",
                        "matchRule": "exact",
                        "value": "value1"
                    }
                ],
          "response": {
            "headers": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ],
            "content": {
              "message": "Success with value1"
            },
            "statusCode": 200
          }
        },
        {
          "cors": true,
          "response": {
            "headers": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ],
            "content": {
              "message": "Success"
            },
            "statusCode": 200
          }
        }
      ]
    }
  ]
}

Keywords

mock server

FAQs

Package last updated on 25 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts