wiremock-rest-client
Advanced tools
Comparing version 1.2.3 to 1.3.0
@@ -13,5 +13,6 @@ "use strict"; | ||
const RecordingService_1 = require("../service/RecordingService"); | ||
const LogUtil_1 = require("../util/LogUtil"); | ||
class WireMockRestClient { | ||
constructor(baseUri) { | ||
loglevel_1.default.getLogger('wiremock-rest-client') | ||
LogUtil_1.LogUtil.logger() | ||
.setLevel(process.env.WRC_LOG_LEVEL || loglevel_1.default.levels.INFO); | ||
@@ -18,0 +19,0 @@ this.baseUri = url_1.resolve(baseUri, '__admin/'); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -13,6 +10,5 @@ if (mod && mod.__esModule) return mod; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const loglevel_1 = __importDefault(require("loglevel")); | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
const logger = loglevel_1.default.getLogger('wiremock-rest-client'); | ||
const LogUtil_1 = require("./LogUtil"); | ||
class FileUtil { | ||
@@ -24,4 +20,4 @@ static getFileContent(fileName) { | ||
catch (error) { | ||
logger.error(`Error: ${error}`); | ||
return process.exit(1); | ||
LogUtil_1.LogUtil.handleError(`Error: ${error}`); | ||
return ''; | ||
} | ||
@@ -43,4 +39,3 @@ } | ||
catch (error) { | ||
logger.error(`Error: ${error}`); | ||
return process.exit(1); | ||
LogUtil_1.LogUtil.handleError(`Error: ${error}`); | ||
} | ||
@@ -47,0 +42,0 @@ return files; |
@@ -15,7 +15,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const loglevel_1 = __importDefault(require("loglevel")); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
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 LogUtil_1 = require("./LogUtil"); | ||
const proxy = process.env.WRC_HTTP_PROXY; | ||
@@ -29,8 +28,8 @@ class HttpUtil { | ||
allOptions.agent = new https_proxy_agent_1.default(proxy); | ||
logger.debug(`[${id}] Using proxy: ${proxy}`); | ||
LogUtil_1.LogUtil.logger().debug(`[${id}] Using proxy: ${proxy}`); | ||
} | ||
try { | ||
logger.info(`[${id}] Request: [${allOptions.method}] ${uri}`); | ||
LogUtil_1.LogUtil.logger().info(`[${id}] Request: [${allOptions.method}] ${uri}`); | ||
if (allOptions.body !== undefined) { | ||
logger.debug(`[${id}] Request body: ${allOptions.body}`); | ||
LogUtil_1.LogUtil.logger().debug(`[${id}] Request body: ${allOptions.body}`); | ||
} | ||
@@ -41,4 +40,4 @@ const response = yield node_fetch_1.default(uri, allOptions); | ||
catch (error) { | ||
logger.error(`[${id}] Error: ${error.message}`); | ||
return process.exit(1); | ||
LogUtil_1.LogUtil.handleError(`[${id}] Error: ${error.message}`); | ||
return ''; | ||
} | ||
@@ -51,6 +50,5 @@ }); | ||
if (!response.ok) { | ||
logger.error(`[${id}] ${responseLog}`); | ||
return process.exit(1); | ||
LogUtil_1.LogUtil.handleError(`[${id}] ${responseLog}`); | ||
} | ||
logger.info(`[${id}] ${responseLog}`); | ||
LogUtil_1.LogUtil.logger().info(`[${id}] ${responseLog}`); | ||
const responseText = yield response.text(); | ||
@@ -57,0 +55,0 @@ try { |
{ | ||
"name": "wiremock-rest-client", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "Lightweight REST client to interact with a running WireMock server", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,3 +13,6 @@ # WireMock REST Client | ||
- [Scenarios](#scenarios) | ||
- [Logging](#logging) | ||
- [Configuration](##configuration) | ||
- [Proxy](#proxy) | ||
- [Log level](#log-level) | ||
- [Continue on failure](#continue-on-failure) | ||
<!-- /TOC --> | ||
@@ -137,3 +140,12 @@ | ||
## Proxy | ||
## Configuration | ||
The following configuration options are available via environment variables. | ||
| Configuration option | Default | Environment variable | | ||
|----------------------------------------------|----------|---------------------------| | ||
| [Proxy](#proxy) | No proxy | `WRC_HTTP_PROXY` | | ||
| [Log level](#log-level) | `info` | `WRC_LOG_LEVEL` | | ||
| [Continue on failure](#continue-on-failure) | `false` | `WRC_CONTINUE_ON_FAILURE` | | ||
### Proxy | ||
A proxy can be set to connect through as follows. | ||
@@ -148,3 +160,3 @@ | ||
## Logging | ||
### Log level | ||
- Default log level is `info` | ||
@@ -156,7 +168,2 @@ - Each log line contains a unique id to trace logs for a single request | ||
Example: | ||
``` | ||
WRC_LOG_LEVEL=debug | ||
``` | ||
```shell | ||
@@ -168,2 +175,6 @@ 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.161Z INFO wiremock-rest-client: [c3690603-c055-4412-a5b0-497704c09dd0] Response: [200] OK | ||
``` | ||
``` | ||
### Continue on failure | ||
- By default the node process is exited in case of a failure | ||
- To change this behavior to continue on failure, set the environment variable `WRC_CONTINUE_ON_FAILURE` to `true` |
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
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
54250
53
1341
176
4