-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from smollweide/develop
v0.17.0
- Loading branch information
Showing
7 changed files
with
559 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var initCli = require('./lib/cli/init-cli'); | ||
initCli(); |
Oops, something went wrong.