@hastehaul/common 2.0.29 → 2.0.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,14 +46,7 @@ class SocketWrapper {
46
46
  // credentials: true,
47
47
  },
48
48
  });
49
- this._io.on("connect", () => {
50
- console.info("Socket.io Server Connected!");
51
- resolve();
52
- });
53
- this._io.on("error", (error) => {
54
- console.error("Error in Socket.io", error);
55
- reject(error);
56
- });
49
+ resolve();
57
50
  });
58
51
  });
59
52
  }
@@ -1,4 +1,10 @@
1
+ type Setting = {
2
+ key: string;
3
+ value: any;
4
+ };
1
5
  export declare function hasElapsed(expirationDate: Date): boolean;
2
6
  export declare function colorize(text: string, colorCode: number): string;
3
7
  export declare function formatDatetimeToHumanReadable(datetime: Date, format?: string): string;
4
8
  export declare function generateIdentifier(messageContent: string): string;
9
+ export declare function getValueFromSettings(settings: Setting[], key: string, envVar: string, defaultValue: any): any;
10
+ export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateIdentifier = exports.formatDatetimeToHumanReadable = exports.colorize = exports.hasElapsed = void 0;
6
+ exports.getValueFromSettings = exports.generateIdentifier = exports.formatDatetimeToHumanReadable = exports.colorize = exports.hasElapsed = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  function hasElapsed(expirationDate) {
9
9
  const currentDate = (0, moment_1.default)();
@@ -25,3 +25,10 @@ function generateIdentifier(messageContent) {
25
25
  return Buffer.from(messageContent).toString('base64');
26
26
  }
27
27
  exports.generateIdentifier = generateIdentifier;
28
+ function getValueFromSettings(settings, key, envVar, defaultValue) {
29
+ const setting = settings.find(item => item.key === key);
30
+ if (setting)
31
+ return setting.value;
32
+ return process.env[envVar] || defaultValue;
33
+ }
34
+ exports.getValueFromSettings = getValueFromSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.0.29",
3
+ "version": "2.0.31",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",