<commit_before># RestServerMock

  A Simple REST HTTP server that serves the configured JSON responses.

## About

  The motivation for implementing this module was to provide a quick and simple server to be used
  when developing a rest client.
  In that cases where the rest server has not been implemented yet,
  I wanted to have an HTTP server responding with some mock JSON responses,
  without relying on a more complex mocking framework.

## Installation

```
npm install rest-server-mock
```

## Configuration

  The server's port and routes are configured in a JSON file:

  Example file:
  ```
  {

    "port": 3001

    , "routes": [

      {
        "path": "/a"
        , "type": "GET"
        , "response": {
          "field_1": "f1 get a ok"
          , "field_2": "f2 get a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "POST"
        , "response": {
          "field_1": "f1 post a ok"
          , "field_2": "f2 post a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "PUT"
        , "response": {
          "field_1": "f1 put a ok"
          , "field_2": "f2 put a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "DELETE"
        , "response": {
          "field_1": "f1 delete a ok"
          , "field_2": "f2 delete a ok"
        }
      }

    ]

  }
  ```
## Usage

### As a commandline tool

```
node rest-server-mock path_to_configuration_file
```

### As a module

```
var restServerMock = require('rest-server-mock') // Include the module.
restServerMock(path_to_configuration_file)       // Start the server. Returns a promise.
.then(function (server) {
    console.log('RestServerMock is listening on port: ', server.address().port, ' ...')
    console.log('Configuration file: ', process.argv[2])
}
, function (err) {
    console.log(err)
})
// Note that the restServerMock method returns a promise.
```

## Running the tests

```
npm test
```<commit_msg>Modify README.<commit_after># RestServerMock

  A Simple REST HTTP server that serves the configured JSON responses.

## About

  The motivation for implementing this module was to provide a quick and simple server to be used
  when developing a rest client.
  In that cases where the rest server has not been implemented yet,
  I wanted to have an HTTP server responding with some mock JSON responses,
  without relying on a more complex mocking framework.

## Installation

```
npm install rest-server-mock
```

## Configuration

  The server's port and routes are configured in a JSON file:

  Example file:
  ```
  {

    "port": 3001

    , "routes": [

      {
        "path": "/a"
        , "type": "GET"
        , "response": {
          "field_1": "f1 get a ok"
          , "field_2": "f2 get a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "POST"
        , "response": {
          "field_1": "f1 post a ok"
          , "field_2": "f2 post a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "PUT"
        , "response": {
          "field_1": "f1 put a ok"
          , "field_2": "f2 put a ok"
        }
      }

      , {
        "path": "/a"
        , "type": "DELETE"
        , "response": {
          "field_1": "f1 delete a ok"
          , "field_2": "f2 delete a ok"
        }
      }

    ]

  }
  ```
## Usage

### As a commandline tool

```
node rest-server-mock path_to_configuration_file
```

### As a module

```
var restServerMock = require('rest-server-mock')            // Include the module.
restServerMock('path_to_configuration_file/filename.json')  // Start the server. Returns a promise.
.then(function (server) {
    console.log('RestServerMock is listening on port: ', server.address().port, ' ...')
    console.log('Configuration file: ', process.argv[2])
}
, function (err) {
    console.log(err)
})
// Note that the restServerMock method returns a promise.
```

## Running the tests

```
npm test
```
{'fraction_non_alphanumeric': 0.13372240548084244, 'fraction_numerical': 0.010657193605683837, 'mean_word_length': 2.096622152395915, 'pattern_counts': {'":': 44, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1902243', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1208, 'n_words': 403}