ismx-nexo-node-app 0.4.170 → 0.4.172

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.
@@ -23,12 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("fs"));
27
- const path = __importStar(require("path"));
28
26
  class BusinessLogger {
29
27
  constructor() {
30
28
  this.logStream = null;
31
29
  this.currentLogFile = null;
30
+ Promise.resolve().then(() => __importStar(require("fs"))).then((e) => this.fs = e.default)
31
+ .catch(() => null);
32
+ Promise.resolve().then(() => __importStar(require("path"))).then((e) => this.path = e.default)
33
+ .catch(() => null);
32
34
  }
33
35
  file() {
34
36
  return null;
@@ -42,16 +44,16 @@ class BusinessLogger {
42
44
  this.logStream.end();
43
45
  this.logStream = null;
44
46
  }
45
- const dir = path.dirname(file);
46
- if (!fs.existsSync(dir))
47
- fs.mkdirSync(dir, { recursive: true });
48
- this.logStream = fs.createWriteStream(file, { flags: 'a', encoding: 'utf8' });
47
+ const dir = this.path.dirname(file);
48
+ if (!this.fs.existsSync(dir))
49
+ this.fs.mkdirSync(dir, { recursive: true });
50
+ this.logStream = this.fs.createWriteStream(file, { flags: 'a', encoding: 'utf8' });
49
51
  this.currentLogFile = file;
50
52
  }
51
53
  if (this.logStream)
52
54
  this.logStream.write(message + '\n');
53
55
  }
54
- log(level, message, writeToFile = false) {
56
+ log(level, message) {
55
57
  const logMessage = `[${level}] ${new Date().toISOString()} -- ${message}`;
56
58
  console.log(logMessage);
57
59
  this.writeToFile(logMessage);
@@ -46,8 +46,10 @@ class BusinessServer extends Business_1.default {
46
46
  }
47
47
  init() {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
- const { default: express } = yield Promise.resolve().then(() => __importStar(require("express")));
50
- const { default: cors } = yield Promise.resolve().then(() => __importStar(require("cors")));
49
+ const express = yield Promise.resolve().then(() => __importStar(require("express"))).then((e) => e.default).catch(() => null);
50
+ const cors = yield Promise.resolve().then(() => __importStar(require("cors"))).then((e) => e.default).catch(() => null);
51
+ if (!express || !cors)
52
+ return;
51
53
  this.express = express;
52
54
  this.app = express();
53
55
  this.app.use(express.urlencoded({ extended: false }));
@@ -1,6 +1,8 @@
1
1
  export default class BusinessLogger {
2
2
  private logStream;
3
3
  private currentLogFile;
4
+ private fs;
5
+ private path;
4
6
  constructor();
5
7
  protected file(): string | null;
6
8
  private writeToFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.170",
3
+ "version": "0.4.172",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -1,13 +1,19 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
1
+ import {WriteStream} from "node:fs";
3
2
 
4
3
  export default class BusinessLogger
5
4
  {
6
- private logStream: fs.WriteStream | null = null;
5
+ private logStream: WriteStream | null = null;
7
6
  private currentLogFile: string | null = null;
7
+ private fs: any;
8
+ private path: any;
8
9
 
9
10
  constructor() {
10
-
11
+ import("fs")
12
+ .then((e) => this.fs = e.default)
13
+ .catch(() => null);
14
+ import("path")
15
+ .then((e) => this.path = e.default)
16
+ .catch(() => null);
11
17
  }
12
18
 
13
19
  protected file(): string | null {
@@ -24,18 +30,18 @@ export default class BusinessLogger
24
30
  this.logStream = null;
25
31
  }
26
32
 
27
- const dir = path.dirname(file);
28
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
29
- this.logStream = fs.createWriteStream(file, { flags: 'a', encoding: 'utf8' });
33
+ const dir = this.path.dirname(file);
34
+ if (!this.fs.existsSync(dir)) this.fs.mkdirSync(dir, { recursive: true });
35
+ this.logStream = this.fs.createWriteStream(file, { flags: 'a', encoding: 'utf8' });
30
36
  this.currentLogFile = file;
31
37
  }
32
38
 
33
39
  if (this.logStream) this.logStream.write(message + '\n');
34
40
  }
35
41
 
36
- private log(level: string, message: string, writeToFile: boolean = false) {
42
+ private log(level: string, message: string) {
37
43
  const logMessage = `[${level}] ${new Date().toISOString()} -- ${message}`;
38
- console.log(logMessage);this.writeToFile(logMessage);
44
+ console.log(logMessage); this.writeToFile(logMessage);
39
45
  }
40
46
 
41
47
  i(message: string) {
@@ -17,8 +17,9 @@ export default class BusinessServer extends Business
17
17
 
18
18
  async init()
19
19
  {
20
- const { default: express } = await import("express");
21
- const { default: cors } = await import("cors");
20
+ const express = await import("express").then((e) => e.default).catch(() => null);
21
+ const cors = await import("cors").then((e) => e.default).catch(() => null);
22
+ if (!express || !cors) return;
22
23
 
23
24
  this.express = express;
24
25
  this.app = express();