Skip to content

Commit

Permalink
Merge pull request #73 from smollweide/develop
Browse files Browse the repository at this point in the history
v0.18.2
  • Loading branch information
smollweide authored Sep 19, 2017
2 parents 6a8ebd6 + bdfd2ad commit ddd44d4
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 74 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[package.json]
indent_style = space
indent_size = 4
2 changes: 1 addition & 1 deletion demo/rest/_fallbacks/#/OPTIONS/mock/success.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
ok: true
"ok": true
}
3 changes: 3 additions & 0 deletions demo/rest/products/#/GET/.store.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
"success.json": {
"counter": 0
},
"tunnel-latest": {
"counter": 0
}
}
}
12 changes: 12 additions & 0 deletions demo/rest/products/#/OPTIONS/desc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"desc": "Returns a list of products (Options)",
"security": [],
"protected": false,
"status": "open",
"response": {
"statusCode": 200,
"schema": {
"type": "application/json"
}
}
}
8 changes: 8 additions & 0 deletions demo/rest/products/#/OPTIONS/mock/error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"errors": [
{
"message": "No valid SearchConfig found for the current context",
"type": "ConversionError"
}
]
}
3 changes: 3 additions & 0 deletions demo/rest/products/#/OPTIONS/mock/success.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"success": true
}
Empty file.
3 changes: 3 additions & 0 deletions demo/rest/products/#/OPTIONS/response_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"success": "boolean"
}
3 changes: 3 additions & 0 deletions demo/rest/products/#{productCode}/POST/.store.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"validation": {
"success": {
"counter": 1
},
"tunnel-latest": {
"counter": 4
}
}
}
8 changes: 8 additions & 0 deletions doc/readme-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,11 @@ Type: `Boolean`
Optional

A boolean to decide to open the UI after start or not.


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

A string that defines and enables the options fallback.
This allows you to define a fallback for every options call except there is one defined for the affected endpoint.
5 changes: 3 additions & 2 deletions lib/controller/MockController.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ MockController.prototype = extend(MockController.prototype, {
var dirSpl = dir.split('/');
var result = true;

if (dirSpl.length !== pathSpl.length) {
// Ignore path length check in case of OPTIONS call because of fallback #68
if (dirSpl.length !== pathSpl.length && options.method !== 'OPTIONS') {
return false;
}

Expand All @@ -476,7 +477,7 @@ MockController.prototype = extend(MockController.prototype, {
var exp = regMatchDyn.exec(dirItem);

if (exp !== null && exp.length > 0) {
if (pathSpl[i] === '' || (/^{([^}]*)}$/).test(pathSpl[i])) {
if (pathSpl[i] === '' || regMatchDyn.test(pathSpl[i])) {
result = false;
}
}
Expand Down
142 changes: 71 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "node-mock-server",
"version": "0.18.1",
"description": "File based Node REST API mock server",
"email": "[email protected]",
"author": "Simon Mollweide <[email protected]>",
"url": "https://github.com/smollweide/node-mock-server",
"repository": {
"type": "github",
"url": "https://github.com/smollweide/node-mock-server"
},
"bugs": {
"url": "https://github.com/smollweide/node-mock-server/issues"
},
"scripts": {
"start": "nodemon demo/index.js",
"test": "mocha test/tests.js",
"posttest": "npm run lint",
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint ."
},
"main": "mock-server.js",
"keywords": [
"node",
"node.js",
"npm",
"mock",
"rest",
"REST",
"rest API",
"REST API",
"api",
"API",
"json",
"DTO",
"Datatransferobject",
"Swagger",
"documentation",
"REST API documentation",
"cli"
],
"engines": {
"node": ">=4"
},
"preferGlobal": false,
"private": false,
"license": "MIT",
"dependencies": {
"body-parser": "^1.15.0",
"chip": "0.0.5",
"cookie-parser": "^1.4.3",
"deasync": "^0.1.4",
"ejs": "^2.4.1",
"es6-promise-polyfill": "^1.2.0",
"express": "^4.15.3",
"extend": "^3.0.0",
"faker": "^4.1.0",
"inflect": "^0.4.0",
"inquirer": "^3.2.1",
"make-dir": "^1.0.0",
"mime-types": "^2.1.15",
"open": "0.0.5",
"p-series": "^1.0.0",
"request": "^2.72.0"
},
"devDependencies": {
"@namics/eslint-config": "^2.2.0",
"babel-eslint": "^6.0.3",
"eslint": "^3.19.0",
"eslint-plugin-import": "^2.2.0",
"mocha": "^2.4.5"
}
"name": "node-mock-server",
"version": "0.18.2",
"description": "File based Node REST API mock server",
"email": "[email protected]",
"author": "Simon Mollweide <[email protected]>",
"url": "https://github.com/smollweide/node-mock-server",
"repository": {
"type": "github",
"url": "https://github.com/smollweide/node-mock-server"
},
"bugs": {
"url": "https://github.com/smollweide/node-mock-server/issues"
},
"scripts": {
"start": "nodemon demo/index.js",
"test": "mocha test/tests.js",
"posttest": "npm run lint",
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint ."
},
"main": "mock-server.js",
"keywords": [
"node",
"node.js",
"npm",
"mock",
"rest",
"REST",
"rest API",
"REST API",
"api",
"API",
"json",
"DTO",
"Datatransferobject",
"Swagger",
"documentation",
"REST API documentation",
"cli"
],
"engines": {
"node": ">=4"
},
"preferGlobal": false,
"private": false,
"license": "MIT",
"dependencies": {
"body-parser": "^1.15.0",
"chip": "0.0.5",
"cookie-parser": "^1.4.3",
"deasync": "^0.1.4",
"ejs": "^2.4.1",
"es6-promise-polyfill": "^1.2.0",
"express": "^4.15.3",
"extend": "^3.0.0",
"faker": "^4.1.0",
"inflect": "^0.4.0",
"inquirer": "^3.2.1",
"make-dir": "^1.0.0",
"mime-types": "^2.1.15",
"open": "0.0.5",
"p-series": "^1.0.0",
"request": "^2.72.0"
},
"devDependencies": {
"@namics/eslint-config": "^4.1.0",
"babel-eslint": "^6.0.3",
"eslint": "^3.19.0",
"eslint-plugin-import": "^2.2.0",
"mocha": "^2.4.5"
}
}

0 comments on commit ddd44d4

Please sign in to comment.