mockapi-msi 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mockapi-config +4 -3
- package/README.md +4 -0
- package/main.js +1 -1
- package/modules/constants.js +1 -1
- package/modules/core.js +5 -2
- package/package.json +1 -1
package/.mockapi-config
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# basic Mock API configuration
|
|
3
3
|
port: 8001
|
|
4
4
|
enableCors: true
|
|
5
|
-
#externalModulesPath: "
|
|
5
|
+
#externalModulesPath: "apiHandlers/"
|
|
6
6
|
|
|
7
7
|
# dummy example configurations
|
|
8
8
|
# PATH must point to a existing CSV file
|
|
@@ -22,9 +22,9 @@ data:
|
|
|
22
22
|
#0...n starting index (always reset to 0 when reach EOR)
|
|
23
23
|
|
|
24
24
|
# custom http response handlers section
|
|
25
|
+
# use: handler unique name : file name within the previously declared folder
|
|
25
26
|
#customHandlers:
|
|
26
|
-
# "custom":
|
|
27
|
-
# "myCustomHandler"
|
|
27
|
+
# "custom": "myCustomHandler"
|
|
28
28
|
|
|
29
29
|
# Mock API available endpoints, return types and
|
|
30
30
|
# general configuration
|
|
@@ -39,6 +39,7 @@ endpoints:
|
|
|
39
39
|
data: myRows
|
|
40
40
|
responseStatus: 200
|
|
41
41
|
responseContentType: "application/json"
|
|
42
|
+
#handler: "custom"
|
|
42
43
|
|
|
43
44
|
log: verbose
|
|
44
45
|
#debug
|
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ MockAPI let you create fake responses with pre defined and dynamic data for defi
|
|
|
6
6
|
|
|
7
7
|
MockAPI also is intended to help you when, during testing phase, you cannot afford complex and expensive products (And you do not need them) that requires bulky configuration steps or depends directly on third party providers that you cannot control.
|
|
8
8
|
|
|
9
|
+
## Version 2.0.1 notes
|
|
10
|
+
|
|
11
|
+
- A bug related to custom handlers was detected and fixed.
|
|
12
|
+
|
|
9
13
|
## Version 2.0.0 notes
|
|
10
14
|
|
|
11
15
|
- Using NodeJS managers such as NVM causes configuration file not being picked from the execution/working folder.
|
package/main.js
CHANGED
|
@@ -32,7 +32,7 @@ if (parsedConfiguration.port === undefined) throw new Error("port property is re
|
|
|
32
32
|
|
|
33
33
|
const logLevel = parsedConfiguration.log || constants.LOG_LEVELS.ALL;
|
|
34
34
|
const log = new LOG(logLevel);
|
|
35
|
-
const moduleProxy = new ModuleProxy(parsedConfiguration.externalModulesPath || constants.EXTERNAL_MODULES_PATH
|
|
35
|
+
const moduleProxy = new ModuleProxy(`file://${rootPath}/${(parsedConfiguration.externalModulesPath || constants.EXTERNAL_MODULES_PATH)}`, log);
|
|
36
36
|
|
|
37
37
|
if (parsedConfiguration.customHandlers !== undefined) {
|
|
38
38
|
moduleProxy.load(parsedConfiguration.customHandlers);
|
package/modules/constants.js
CHANGED
package/modules/core.js
CHANGED
|
@@ -74,8 +74,11 @@ class Core {
|
|
|
74
74
|
self._data[endpoint.data].dataHandler(urlInformation);
|
|
75
75
|
|
|
76
76
|
responseBody = endpoint.handler !== undefined ?
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
self._modulesProxy.execute(endpoint.handler, {
|
|
78
|
+
method: requestMethod,
|
|
79
|
+
url: endpointUrl,
|
|
80
|
+
body: bodyPayload
|
|
81
|
+
}, processData) : processData;
|
|
79
82
|
|
|
80
83
|
responseStatus = endpoint.responseStatus;
|
|
81
84
|
} catch(ex) {
|