new Mockettaro( [ directory [, responseDelay [, cacheLifetime [, cwd [, verbose [, errors [, info ] ] ] ] ] ] ] ) → {Express}

Description
Creates an instance of Mockettaro.
Parameters
Name Type Attributes Default Description
directory string <optional>
'./' Mock source path
responseDelay number <optional>
0 Response delay to simulate
cacheLifetime number <optional>
3000 Response Codes and Bodies cache life time
cwd string <optional>
__dirname Current working dir, __dirname as default
verbose Object <optional>
false Verbose log level
errors Object <optional>
true Error log level
info Object <optional>
true Info log level
Returns
Express instance
Examples
new Mockettaro({directory: './'})
Details

Members


<static, readonly> ABSOLUTE_PATH_MATCHER

Description
Absolute path win/*nix
Properties
Name Type Description
ABSOLUTE_PATH_MATCHER Regexp Regular expression to match an absolute win/*nix path
Examples
Mockettaro.ABSOLUTE_PATH_MATCHER
Details

Methods


<static> resourceConfigRoute( req, res, next )

Description
Configuration Route
Parameters
Name Type Description
req Express.Request Request / previous route params
res Express.Response Response instance
next function Callback to be called to step forward in route chain
Examples
const express = require('express');<br>const app = express();<br>...<br>app.use(Mockettaro.resourceConfigRoute);
Details

<static> returnResponse( req, res )

Description
Configuration Route
Parameters
Name Type Description
req Express.Request Request / previous route params
res Express.Response Response instance
Examples
const express = require('express');<br>const app = express();<br>...<br>app.use(Mockettaro.returnResponse);
Details

<static> errorHandler( err [, req ], res [, next ] )

Description
Error Handler Route
Parameters
Name Type Attributes Description
err string | Error Raised error
req Express.Request <optional>
Request / previous route params
res Express.Response Response instance
next function <optional>
Callback to be called to step forward in route chain, needed for Express to manage it as an Error Handler
Examples
const express = require('express');<br>const app = express();<br>...<br>app.use(Mockettaro.errorHandler);
Details