1.3.1 • Published 8 years ago

easy-mocker v1.3.1

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

EASY MOCKER

Build Status

NPM

This is a NodeJs webserver intended for development. It provides a basic and quick way to define mock response trough a collection of JSON responses and a JSON file containing endpoint definition.

Installation

Grab it form npm: npm install easy-mocker

Minimum usage: easy-mocker -c config.json -d folder/

Configuration

OptionValueDescription
-c*path/to/config.jsonPath to api definition
-d*path/to/mock-directoryPath to mock folder
-pportWebserver port
-unullReturn different models for different user

Options marked with * are mandatory.mv m

Configuration file

This is a sample structure for a configuration file:

{
  "auth": {
    "headerField": "x-randomField" //optional (default to `x-userid`)
  },
  "endpoints": [
    {
      "url": "users",
      "base": "api/",
      "methods": ["GET"],
      "param": "id"
    },
    {
      "url": "posts",
      "base": "api/",
      "methods": ["GET", "POST"],
      "param": "id"
    }
  ]
}

That will generate the following endpoints:

  • GET /api/users
  • GET /api/users/:id
  • GET /api/posts
  • GET /api/posts/:id
  • POST /api/posts
  • POST /api/posts/:id

MOCK Files

You can provide data to be loaded as a starting point for your development server. They should be located in the Mock Folder directory (-d option).

Examples for this files can be found in spec/mocks, anyway they are plain JSON arrays of objects.

1.3.1

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago