apm-optima 1.0.2 → 1.0.3

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.
@@ -5,6 +5,7 @@ declare class Logger {
5
5
  private static readonly DIM;
6
6
  private static readonly COLORS;
7
7
  static log(req: Request, res: Response, duration: number): void;
8
+ static error(message: string, ...args: unknown[]): void;
8
9
  static debug(message: string, ...args: unknown[]): void;
9
10
  static duration(message: string, duration: number): void;
10
11
  }
@@ -41,6 +41,10 @@ class Logger {
41
41
  `• ${statusCode} • ` +
42
42
  `${timing}`);
43
43
  }
44
+ static error(message, ...args) {
45
+ const timestamp = new Date().toISOString().split('T')[1].slice(0, -1);
46
+ console.error(`${Logger.DIM}[${timestamp}]${Logger.RESET} [Optima] ${Logger.COLORS.ERROR}${message}${Logger.RESET}`, ...args);
47
+ }
44
48
  static debug(message, ...args) {
45
49
  const timestamp = new Date().toISOString().split('T')[1].slice(0, -1);
46
50
  console.log(`${Logger.DIM}[${timestamp}]${Logger.RESET} [Optima] ${Logger.DIM}${message}${Logger.RESET}`, ...args);
@@ -6,10 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.attachDashboard = attachDashboard;
7
7
  const express_1 = __importDefault(require("express"));
8
8
  const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const logger_1 = __importDefault(require("../core/telemetry/logger"));
9
11
  function attachDashboard(app, routePath = '/dashboard') {
10
- const staticAssetsPath = path_1.default.resolve(__dirname, '../../../dashboard/out');
11
- app.use(routePath, express_1.default.static(staticAssetsPath));
12
- app.get(`${routePath}/*`, (req, res) => {
13
- res.sendFile(path_1.default.join(staticAssetsPath, 'index.html'));
12
+ const dashboardDir = path_1.default.join(__dirname, '../../dashboard-out');
13
+ const indexHtmlPath = path_1.default.join(dashboardDir, 'index.html');
14
+ if (!fs_1.default.existsSync(indexHtmlPath)) {
15
+ logger_1.default.error(`Dashboard not found at ${indexHtmlPath}. Please build the dashboard first.`);
16
+ return;
17
+ }
18
+ app.use(routePath, express_1.default.static(dashboardDir));
19
+ app.get(`${routePath}*`, (req, res) => {
20
+ res.sendFile(indexHtmlPath);
14
21
  });
15
22
  }
@@ -21,6 +21,8 @@ const metrics_websocket_adapter_1 = require("./metrics-websocket.adapter");
21
21
  const metrics_bootstrap_service_1 = require("./metrics.bootstrap.service");
22
22
  const telemetry_service_1 = __importDefault(require("../core/telemetry/telemetry.service"));
23
23
  const config_1 = require("../config");
24
+ const fs_1 = __importDefault(require("fs"));
25
+ const logger_1 = __importDefault(require("../core/telemetry/logger"));
24
26
  let MetricsModule = MetricsModule_1 = class MetricsModule {
25
27
  static forRoot(options) {
26
28
  config_1.ConfigManager.getInstance().initialize(options);
@@ -41,12 +43,17 @@ let MetricsModule = MetricsModule_1 = class MetricsModule {
41
43
  return;
42
44
  }
43
45
  const dashboardRoute = config.dashboardPath;
44
- const staticAssetsPath = path_1.default.resolve(__dirname, '../../../dashboard/out');
46
+ const dashboardDir = path_1.default.join(__dirname, '../../dashboard-out');
47
+ const indexHtmlPath = path_1.default.join(dashboardDir, 'index.html');
48
+ if (!fs_1.default.existsSync(indexHtmlPath)) {
49
+ logger_1.default.error(`Dashboard not found at ${indexHtmlPath}. Please build the dashboard first.`);
50
+ return;
51
+ }
45
52
  consumer
46
- .apply(express_1.default.static(staticAssetsPath), (req, res, next) => {
53
+ .apply(express_1.default.static(dashboardDir), (req, res, next) => {
47
54
  // SPA Fallback
48
55
  if (!req.path.includes('.')) {
49
- return res.sendFile(path_1.default.join(staticAssetsPath, 'index.html'));
56
+ return res.sendFile(indexHtmlPath);
50
57
  }
51
58
  next();
52
59
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apm-optima",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "publishConfig": {