Skip to content

Commit

Permalink
v 1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Marketto committed Nov 24, 2019
1 parent f493ac2 commit c361e72
Show file tree
Hide file tree
Showing 42 changed files with 5,567 additions and 5,155 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
Expand Down
15 changes: 15 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"include": [
"lib/**/*.js",
"bin/**/*.js"
],
"exclude": [
"**/docs/**/*",
"**/examples/**/*"
],
"reporter": [
"lcovonly",
"text",
"text-summary"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"jslint.enable": false,
"jshint.enable": false,
"previewjsdoc.confFile": "./jsdoc.json",
"tslint.enable": false
"tslint.enable": false,
"coverage-gutters.lcovname": "coverage/lcov.info"
}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Instant Server for JSON and XML Mocks with support for REST structure, VERB spec
* **.code** => *plain text with custom response status code*
* **.schema.json** => *request validator*

## Supported responses
* **JSON** => *Default*
* **XML** => *"Accept"*: ***"application/xml"***

## Installation
### Global
#### npm
Expand Down Expand Up @@ -151,6 +155,7 @@ In your Mock folder (anywhere) create the following folder structure:
/
├── customer
│ ├── foo.GET.json
│ ├── foo.GET.delay
│ ├── default.PUT.schema.json
│ ├── default.PUT.json
│ ├── foo.DELETE.code
Expand Down Expand Up @@ -187,6 +192,12 @@ In your Mock folder (anywhere) create the following folder structure:
}
```

#### customer/foo.GET.delay
Delay in milliseconds for the matching resource
```text
500
```

#### customer/default.GET.json
```json
{
Expand Down Expand Up @@ -234,6 +245,7 @@ All PUT request to /customer/xxxx will be validated against it!
```

#### customer/foo.DELETE.code
Status code to return in response for the matching resource
```text
204
```
Expand Down Expand Up @@ -288,9 +300,14 @@ All POST request to /customer , if passing validation, will have a response with
```

#### Run mock server
##### Global
```{r, engine='bash', run}
mockettaro -r services
```
##### NPX
```{r, engine='bash', run}
npx mockettaro -r services
```

#### URL to test
* http://localhost:8080/services/customer GET, POST
Expand All @@ -300,6 +317,14 @@ mockettaro -r services


## Changelog
### 1.4.3
- Fixed delay parameter bug
- Fixed resource delay cache bug
- Package json scripts now use npx
- Tests and coverage use only nyc and mocha
- Mocha and Nyc config/parameters moved to test/mocha.opts and .nycrc.json
- jsdoc comments review
- Increased test coverage over classes (error handling focused)
### 1.4.2
- Improved performance implementing iterators
- Implemented xml support for mocks
Expand Down
65 changes: 29 additions & 36 deletions docs/Mockettaro.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ <h4 id=".ABSOLUTE_PATH_MATCHER" class="member public"><span class="signature-att
<div class="symbol-details-inner">
<div class="callout callout-primary"><h5>Description</h5> <div class="description">Absolute path win/*nix</div>
</div> <div class="callout callout-info">
<h5>Parameters</h5>
<h5>Properties</h5>
<table class="params table table-striped">
<thead>
<tr>
Expand All @@ -225,22 +225,15 @@ <h5>Parameters</h5>
<tbody>
<tr>
<td><code>ABSOLUTE_PATH_MATCHER</code></td>
<td></td>
<td><span class="param-type">Regexp</span></td>
<td class="last">
Regular expression to match an absolute win/*nix path
</td>
</tr>
</tbody>
</table>
</div>
<div class="callout callout-success"><h5>Returns</h5> <form class="form-horizontal returns">
<div class="form-group">
<label class="col-sm-3 control-label returns-type"><span class="param-type">Regexp</span></label>
<div class="col-sm-9">
<div class="form-control-static returns-description">Regular expression to match an absolute win/*nix path</div>
</div>
</div>
</form>
</div> <div class="callout callout-example"><h5>Examples</h5> <div class="example-code">
<div class="callout callout-example"><h5>Examples</h5> <div class="example-code">
<pre class="prettyprint source language-javascript"><code class="language-javascript">Mockettaro.ABSOLUTE_PATH_MATCHER</code></pre>
</div>
</div> <div class="callout callout-default"><h5>Details</h5> <form class="form-horizontal details">
Expand All @@ -263,7 +256,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-66">line 66</a></p>
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-65">line 65</a></p>
</div>
</div>

Expand All @@ -278,60 +271,48 @@ <h3>Methods</h3>
<dl class="symbol">
<hr/>
<dt class="symbol-title function public collapsible-symbol">
<h4 id=".errorHandler" class="function public"><span class="signature-attribs">&lt;static> </span><span class="name">errorHandler</span><span class="signature-params">( <span class="signature-param">err</span> [,&nbsp;<span class="signature-param">req</span>&nbsp;], <span class="signature-param">res</span> [,&nbsp;<span class="signature-param">next</span>&nbsp;]&nbsp;)</span><span class="signature-type"></span></h4>
<h4 id=".configRoute" class="function public"><span class="signature-attribs">&lt;static> </span><span class="name">configRoute</span><span class="signature-params">( <span class="signature-param">req</span>, <span class="signature-param">res</span>, <span class="signature-param">next</span>&nbsp;)</span><span class="signature-type"></span></h4>
</dt>
<dd class="symbol-details function public collapsible-symbol">
<div class="symbol-details-inner">
<div class="callout callout-primary"><h5>Description</h5> <div class="description">Error Handler Route</div>
<div class="callout callout-primary"><h5>Description</h5> <div class="description">Configuration Route</div>
</div> <div class="callout callout-info">
<h5>Parameters</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>err</code></td>
<td><span class="param-type">string</span> | <span class="param-type">Error</span></td>
<td class="attributes"></td>
<td class="last">
Raised error
</td>
</tr>
<tr>
<td><code>req</code></td>
<td><span class="param-type">Express.Request</span></td>
<td class="attributes">&lt;optional&gt;<br/></td>
<td class="last">
Request / previous route params
</td>
</tr>
<tr>
<td><code>res</code></td>
<td><span class="param-type">Express.Response</span></td>
<td class="attributes"></td>
<td class="last">
Response instance
</td>
</tr>
<tr>
<td><code>next</code></td>
<td><span class="param-type">function</span></td>
<td class="attributes">&lt;optional&gt;<br/></td>
<td class="last">
Callback to be called to step forward in route chain, needed for Express to manage it as an Error Handler
Callback to be called to step forward in route chain
</td>
</tr>
</tbody>
</table>
</div>
<div class="callout callout-example"><h5>Examples</h5> <div class="example-code">
<pre class="prettyprint source language-javascript"><code class="language-javascript">const express &#x3D; require(&#x27;express&#x27;);&lt;br&gt;const app &#x3D; express();&lt;br&gt;...&lt;br&gt;app.use(Mockettaro.errorHandler);</code></pre>
<pre class="prettyprint source language-javascript"><code class="language-javascript">const express &#x3D; require(&#x27;express&#x27;);&lt;br&gt;const app &#x3D; express();&lt;br&gt;...&lt;br&gt;app.use(Mockettaro.configRoute);</code></pre>
</div>
</div> <div class="callout callout-default"><h5>Details</h5> <form class="form-horizontal details">

Expand All @@ -353,7 +334,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-120">line 120</a></p>
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-69">line 69</a></p>
</div>
</div>

Expand Down Expand Up @@ -421,7 +402,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-89">line 89</a></p>
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-86">line 86</a></p>
</div>
</div>

Expand All @@ -433,48 +414,60 @@ <h5>Parameters</h5>
</dd>
<hr/>
<dt class="symbol-title function public collapsible-symbol">
<h4 id=".configRoute" class="function public"><span class="signature-attribs">&lt;static> </span><span class="name">configRoute</span><span class="signature-params">( <span class="signature-param">req</span>, <span class="signature-param">res</span>, <span class="signature-param">next</span>&nbsp;)</span><span class="signature-type"></span></h4>
<h4 id=".errorHandler" class="function public"><span class="signature-attribs">&lt;static> </span><span class="name">errorHandler</span><span class="signature-params">( <span class="signature-param">err</span> [,&nbsp;<span class="signature-param">req</span>&nbsp;], <span class="signature-param">res</span> [,&nbsp;<span class="signature-param">next</span>&nbsp;]&nbsp;)</span><span class="signature-type"></span></h4>
</dt>
<dd class="symbol-details function public collapsible-symbol">
<div class="symbol-details-inner">
<div class="callout callout-primary"><h5>Description</h5> <div class="description">Configuration Route</div>
<div class="callout callout-primary"><h5>Description</h5> <div class="description">Error Handler Route</div>
</div> <div class="callout callout-info">
<h5>Parameters</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>err</code></td>
<td><span class="param-type">string</span> | <span class="param-type">Error</span></td>
<td class="attributes"></td>
<td class="last">
Raised error
</td>
</tr>
<tr>
<td><code>req</code></td>
<td><span class="param-type">Express.Request</span></td>
<td class="attributes">&lt;optional&gt;<br/></td>
<td class="last">
Request / previous route params
</td>
</tr>
<tr>
<td><code>res</code></td>
<td><span class="param-type">Express.Response</span></td>
<td class="attributes"></td>
<td class="last">
Response instance
</td>
</tr>
<tr>
<td><code>next</code></td>
<td><span class="param-type">function</span></td>
<td class="attributes">&lt;optional&gt;<br/></td>
<td class="last">
Callback to be called to step forward in route chain
Callback to be called to step forward in route chain, needed for Express to manage it as an Error Handler
</td>
</tr>
</tbody>
</table>
</div>
<div class="callout callout-example"><h5>Examples</h5> <div class="example-code">
<pre class="prettyprint source language-javascript"><code class="language-javascript">const express &#x3D; require(&#x27;express&#x27;);&lt;br&gt;const app &#x3D; express();&lt;br&gt;...&lt;br&gt;app.use(Mockettaro.configRoute);</code></pre>
<pre class="prettyprint source language-javascript"><code class="language-javascript">const express &#x3D; require(&#x27;express&#x27;);&lt;br&gt;const app &#x3D; express();&lt;br&gt;...&lt;br&gt;app.use(Mockettaro.errorHandler);</code></pre>
</div>
</div> <div class="callout callout-default"><h5>Details</h5> <form class="form-horizontal details">

Expand All @@ -496,7 +489,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-70">line 70</a></p>
<p class="form-control-static"><a href="mockettaro.class.js.html">mockettaro.class.js</a>, <a href="mockettaro.class.js.html#line-115">line 115</a></p>
</div>
</div>

Expand All @@ -517,7 +510,7 @@ <h5>Parameters</h5>
</div>
<footer>
<div class="copyright">FooDoc Copyright © 2016 The contributors to the JSDoc3 and FooDoc projects.</div>
<div class="generated-by">Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on 2nd Nov 2019 using the <a href="https://github.com/steveush/foodoc">FooDoc template</a>.</div>
<div class="generated-by">Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on 25th Nov 2019 using the <a href="https://github.com/steveush/foodoc">FooDoc template</a>.</div>
</footer>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
Expand Down
Loading

0 comments on commit c361e72

Please sign in to comment.