@ikonintegration/ikapi 3.0.5 → 3.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/ikapi",
3
- "version": "3.0.5",
3
+ "version": "3.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -10,6 +10,7 @@ export default class IKResponse {
10
10
  this._isStream = false; //
11
11
  this._contextRawBody = false;
12
12
  this._throwOnErrors = false;
13
+ this.disableTransactionID = false;
13
14
  //
14
15
  this._headers = {
15
16
  "Access-Control-Allow-Origin": "*",
@@ -27,7 +28,7 @@ export default class IKResponse {
27
28
  if (this._isStream) return this._pipe(context);
28
29
 
29
30
  //append default fields
30
- if (transaction.request.getRequestID() && this._body) this.appendIntoBody('transactionID', transaction.request.getRequestID()); //append transaction ID
31
+ if (transaction.request.getRequestID() && this._body && !this.disableTransactionID) this.appendIntoBody('transactionID', transaction.request.getRequestID()); //append transaction ID
31
32
  //Raw response support
32
33
  if (this._contextRawBody) return this.rawContext(context, transaction);
33
34
 
@@ -4,7 +4,7 @@ import { convertToAttr, marshall, unmarshall } from "@aws-sdk/util-dynamodb";
4
4
  //
5
5
  export default class IKUtils {}
6
6
  IKUtils.isOffline = function() { return process.env.IS_OFFLINE; }
7
- IKUtils.isIKAPIGateway = function() { return process.env.IS_IKAPIGATEWAY; }
7
+ IKUtils.isHybridlessContainer = function() { return process.env.HYBRIDLESS_RUNTIME; }
8
8
  IKUtils.logLevel = function() { return process.env.LOG_LEVEL; }
9
9
 
10
10
  //formatting
@@ -21,12 +21,14 @@ export default class IKDB_DDB extends IKDB {
21
21
  // if (config && this.tableName) { localConsole.debug(`Using table: ${this.tableName} on region: ${this.region}`); }
22
22
  }
23
23
 
24
- async _getConnection() {
25
- if ((!DDB_CONN && !DDB_CONN_HASH) || DDB_CONN_HASH != sha1(this.region)) DDB_CONN = await this._newConnection(this.config);
26
- return DDB_CONN;
27
- }
28
24
  async connect() {
29
25
  const localConsole = (this.transaction ? this.transaction.logger : console);
26
+ //Reusability logic
27
+ if (!((!DDB_CONN && !DDB_CONN_HASH) || DDB_CONN_HASH != sha1(this.region))) {
28
+ localConsole.debug("Reusing database connection");
29
+ this.connection = DDB_CONN;
30
+ return;
31
+ }
30
32
  //setup db
31
33
  if (Utils.isOffline()) {
32
34
  localConsole.debug("Starting offline database connection");
@@ -79,7 +79,7 @@ export default class IKLogger {
79
79
  _formattedLog(level, msg, caller, isRaw) {
80
80
  if (Utils.isOffline()) {
81
81
  return ` [${this._timestamp()} - ${LOG_STRINGS[level]}] [${caller}] ${msg.join(" ")}`;
82
- } else if (Utils.isIKAPIGateway() && this._transactionID) {
82
+ } else if (Utils.isHybridlessContainer() && this._transactionID) {
83
83
  return (isRaw ? '' : ` ${this._transactionID}`) + ` [${LOG_STRINGS[level]}] [${caller}] ${this._supressSensitiveInfo(msg.join(" "))}`;
84
84
  } else {
85
85
  return ` [${LOG_STRINGS[level]}] [${caller}] ${msg.join(" ")}`;