Skip to content

Commit

Permalink
Merge pull request #51 from smollweide/develop
Browse files Browse the repository at this point in the history
v0.17.0
  • Loading branch information
smollweide authored Jul 29, 2017
2 parents a6481b0 + 5d2c2e1 commit 0785b26
Show file tree
Hide file tree
Showing 7 changed files with 559 additions and 75 deletions.
15 changes: 8 additions & 7 deletions doc/readme-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ Optional

A object that define the swagger import.

#### options.customDTOToClassTemplate
Type: `String`
Optional

A string that define the path to the custom DTO to class template.
[template](/src/templates/dto_es6flow.ejs)

#### options.swaggerImport.protocol
Type: `String`
Default value: `http`
Expand Down Expand Up @@ -210,3 +203,11 @@ A boolean to decide to replace an old description with the new (imported) descri
Type: `String`

A string that defines the location of the imported response functions.


#### options.customDTOToClassTemplate
Type: `String`
Optional

A string that define the path to the custom DTO to class template.
[template](/src/templates/dto_es6flow.ejs)
63 changes: 63 additions & 0 deletions doc/readme-usage-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

# Usage examples

## Default Options
```js
var mockServer = require('node-mock-server');
mockServer({});
```

## Custom Options

```js
var mockServer = require('node-mock-server');
var path = require('path');

mockServer({
restPath: path.join(__dirname, '/mock/rest'),
dirName: __dirname,
title: 'Api mock server',
version: 2,
urlBase: 'http://localhost:3003',
urlPath: '/rest/v2',
port: 3003,
uiPath: '/',
funcPath: path.join(__dirname, '/func'),
headers: {
'Global-Custom-Header': 'Global-Custom-Header'
},
customDTOToClassTemplate: path.join(__dirname, '/templates/dto_es6flow.ejs'),
middleware: {
'/rest/products/#{productCode}/GET'(serverOptions, requestOptions) {
var productCode = requestOptions.req.params[0].split('/')[3];

if (productCode === '1234') {
requestOptions.res.statusCode = 201;
requestOptions.res.end('product 1234');
return null;
}

return 'success';
}
},
expressMiddleware: [
function (express) {
return ['/public', express.static(__dirname + '/public')];
}
],
swaggerImport: {
protocol: 'http',
authUser: undefined,
authPass: undefined,
host: 'petstore.swagger.io',
port: 80,
path: '/v2/swagger.json',
dest: path.join(__dirname, '/mock/rest'),
replacePathsStr: '/v2/{baseSiteId}',
createErrorFile: true,
createEmptyFile: true,
overwriteExistingDescriptions: true,
responseFuncPath: path.join(__dirname, '/func-imported')
}
});
```
2 changes: 2 additions & 0 deletions init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var initCli = require('./lib/cli/init-cli');
initCli();
Loading

0 comments on commit 0785b26

Please sign in to comment.