1.0.1 • Published 7 years ago

chuckyeager v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Chuck Yeager

Named after the first American pilot to break the 'Mach' barrier, this tool assists in the rapid development of 'Mock' APIs for use in integration testing

Installation

Install this package from the NPM repository

npm install chuckyeager

Usage

1: Configure the models

The express server will create routes and response handlers based upon the contents of the Models sub-directory in this project. Each JSON model will be available at the specified path. In addition, routes will automatically be created so that a request made appending /YAML or /XML will deliver the model data in those respective formats.

To create mocks, simply place a JSON file in that directory that conforms to this structure:

{
  "response":{
    "method":"get",
    "path":"/examples",
    "statusCode":200,
    "body":{
      "examples":[
        {"firstName":"John","lastname":"Doe"}
      ]
    }
  }
}

The following properties of the JSON object can be adjusted or removed (in which case defaults will be used):

PropertyUsageDefault Value
methodDefines the HTTP Method for the Express RouteGET
pathDefines the relative path for the route (should be unique across the directory)/
statusCodeThe HTTP Code to send with the response200
bodyJSON body to send with the response{}

2: Start the Server

node index.js

Test it out

From the terminal, curl the local server and request the examples model(s):

curl http://localhost/examples
curl http://localhost/examples/xml
curl http://localhost/examples/yaml