wiremock-rest-client
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -23,3 +23,3 @@ "use strict"; | ||
catch (error) { | ||
logger.error(`[ERROR] ${error}`); | ||
logger.error(`Error: ${error}`); | ||
return process.exit(1); | ||
@@ -42,3 +42,3 @@ } | ||
catch (error) { | ||
logger.error(`[ERROR] ${error}`); | ||
logger.error(`Error: ${error}`); | ||
return process.exit(1); | ||
@@ -45,0 +45,0 @@ } |
@@ -18,3 +18,5 @@ "use strict"; | ||
const v4_1 = __importDefault(require("uuid/v4")); | ||
const https_proxy_agent_1 = __importDefault(require("https-proxy-agent")); | ||
const logger = loglevel_1.default.getLogger('wiremock-rest-client'); | ||
const proxy = process.env.WRC_HTTP_PROXY; | ||
class HttpUtil { | ||
@@ -25,6 +27,10 @@ static fetch(uri, options) { | ||
const allOptions = Object.assign({ 'Content-Type': 'application/json' }, options); | ||
if (proxy) { | ||
allOptions.agent = new https_proxy_agent_1.default(proxy); | ||
logger.debug(`[${id}] Using proxy: ${proxy}`); | ||
} | ||
try { | ||
logger.info(`[${id}] [INFO] Request: [${allOptions.method}] ${uri}`); | ||
logger.info(`[${id}] Request: [${allOptions.method}] ${uri}`); | ||
if (allOptions.body !== undefined) { | ||
logger.debug(`[${id}] [DEBUG] Request body: ${allOptions.body}`); | ||
logger.debug(`[${id}] Request body: ${allOptions.body}`); | ||
} | ||
@@ -35,3 +41,3 @@ const response = yield node_fetch_1.default(uri, allOptions); | ||
catch (error) { | ||
logger.error(`[${id}] [ERROR] Error: ${error.message}`); | ||
logger.error(`[${id}] Error: ${error.message}`); | ||
return process.exit(1); | ||
@@ -45,6 +51,6 @@ } | ||
if (!response.ok) { | ||
logger.error(`[${id}] [ERROR] ${responseLog}`); | ||
logger.error(`[${id}] ${responseLog}`); | ||
return process.exit(1); | ||
} | ||
logger.info(`[${id}] [INFO] ${responseLog}`); | ||
logger.info(`[${id}] ${responseLog}`); | ||
const responseText = yield response.text(); | ||
@@ -51,0 +57,0 @@ try { |
{ | ||
"name": "wiremock-rest-client", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Lightweight REST client to interact with a running WireMock server", | ||
@@ -36,18 +36,19 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"loglevel": "1.6.6", | ||
"node-fetch": "2.6.0", | ||
"https-proxy-agent": "^4.0.0", | ||
"loglevel": "^1.6.6", | ||
"node-fetch": "^2.6.0", | ||
"uuid": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "12.11.7", | ||
"@types/node-fetch": "2.5.2", | ||
"@typescript-eslint/eslint-plugin": "2.5.0", | ||
"@typescript-eslint/parser": "2.5.0", | ||
"dtsgenerator": "2.3.1", | ||
"eslint": "6.6.0", | ||
"eslint-config-airbnb-base": "14.0.0", | ||
"eslint-import-resolver-typescript": "2.0.0", | ||
"eslint-plugin-import": "2.18.2", | ||
"typescript": "3.6.4" | ||
"@types/node": "^12.11.7", | ||
"@types/node-fetch": "^2.5.2", | ||
"@typescript-eslint/eslint-plugin": "^2.5.0", | ||
"@typescript-eslint/parser": "^2.5.0", | ||
"dtsgenerator": "^2.3.1", | ||
"eslint": "^6.6.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-import-resolver-typescript": "^2.0.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"typescript": "^3.6.4" | ||
} | ||
} |
@@ -136,2 +136,12 @@ # WireMock REST Client | ||
## Proxy | ||
A proxy can be set to connect through as follows. | ||
Set the environment variable `WRC_HTTP_PROXY` to the proxy url. The proxy URL can be HTTP or HTTPS. Credentials for authentication can be passed in the URL. | ||
Example: | ||
``` | ||
WRC_HTTP_PROXY=http://username:secret@mycorporateproxy.com | ||
``` | ||
## Logging | ||
@@ -144,9 +154,13 @@ - Default log level is `info` | ||
**Example:** | ||
Example: | ||
``` | ||
WRC_LOG_LEVEL=debug | ||
``` | ||
```shell | ||
[10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] [INFO] Request: [POST] http://localhost:8080/__admin/mappings | ||
[10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] [DEBUG] Request body: {"request":{"method":"GET","urlPathPattern":"/api/helloworld"},"response":{"status":200,"jsonBody":{"hello":"world"},"headers":{"Content-Type":"application/json"}}} | ||
[10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] [INFO] Response: [201] Created | ||
[c3690603-c055-4412-a5b0-497704c09dd0] [INFO] Request: [POST] http://localhost:8080/__admin/shutdown | ||
[c3690603-c055-4412-a5b0-497704c09dd0] [INFO] Response: [200] OK | ||
2019-12-11T20:43:18.157Z INFO wiremock-rest-client: [10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] Request: [POST] http://localhost:8080/__admin/mappings | ||
2019-12-11T20:43:18.157Z DEBUG wiremock-rest-client: [10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] Request body: {"request":{"method":"GET","urlPathPattern":"/api/helloworld"},"response":{"status":200,"jsonBody":{"hello":"world"},"headers":{"Content-Type":"application/json"}}} | ||
2019-12-11T20:43:18.158Z INFO wiremock-rest-client: [10f7dcb9-b8a3-4598-8751-40edb0bd5d2e] Response: [201] Created | ||
2019-12-11T20:43:18.158Z INFO wiremock-rest-client: [c3690603-c055-4412-a5b0-497704c09dd0] Request: [POST] http://localhost:8080/__admin/shutdown | ||
2019-12-11T20:43:18.161Z INFO wiremock-rest-client: [c3690603-c055-4412-a5b0-497704c09dd0] Response: [200] OK | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52107
1297
164
4
3
1
+ Addedhttps-proxy-agent@^4.0.0
+ Addedagent-base@5.1.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedhttps-proxy-agent@4.0.0(transitive)
+ Addedloglevel@1.9.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedloglevel@1.6.6(transitive)
- Removednode-fetch@2.6.0(transitive)
Updatedloglevel@^1.6.6
Updatednode-fetch@^2.6.0