@aromix/core 0.4.3 → 0.4.4

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/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ declare class App {
15
15
  private blocks;
16
16
  private errorHandlers;
17
17
  use(block: Block): void;
18
- onError(handler: ErrorHandler): this;
18
+ onError(handler: ErrorHandler): void;
19
19
  start(): Promise<void>;
20
20
  stop(): Promise<void>;
21
21
  private notifyError;
package/dist/index.js CHANGED
@@ -12,42 +12,34 @@ var App = class {
12
12
  throw new Error(`[Aromix] Block with name "${block.name}" is already registered.`);
13
13
  }
14
14
  this.blocks.push(block);
15
- console.debug("[Aromix] Block registered", { block: block.name, phase: "register" });
16
15
  }
17
16
  onError(handler) {
18
17
  this.errorHandlers.push(handler);
19
- return this;
20
18
  }
21
19
  async start() {
22
20
  if (this.isStarted) {
23
21
  throw new Error("[Aromix] Process has already been started.");
24
22
  }
25
23
  this.isStarted = true;
26
- console.info("[Aromix] Starting application", { totalBlocks: this.blocks.length });
27
24
  for (const block of this.blocks) {
28
25
  const startedAt = Date.now();
29
26
  try {
30
27
  await block.start();
31
- console.log("[Aromix] Block started", { block: block.name, phase: "start", durationMs: Date.now() - startedAt });
32
28
  } catch (err) {
33
- console.error("[Aromix] Fatal: block failed to start. Rolling back...", err, { block: block.name, phase: "start" });
34
29
  await this.notifyError(err, "start", block);
35
30
  await this.stopAll("start-failure");
36
31
  process.exit(1);
37
32
  }
38
33
  }
39
34
  process.on("uncaughtException", (err) => {
40
- console.error("[Aromix] Uncaught exception. Shutting down...", err);
41
35
  this.notifyError(err, "runtime").finally(() => this.gracefulShutdown("uncaughtException"));
42
36
  });
43
37
  process.on("unhandledRejection", (reason) => {
44
38
  const err = reason instanceof Error ? reason : new Error(String(reason));
45
- console.error("[Aromix] Unhandled rejection. Shutting down...", err);
46
39
  this.notifyError(err, "runtime").finally(() => this.gracefulShutdown("unhandledRejection"));
47
40
  });
48
41
  process.once("SIGINT", () => this.gracefulShutdown("SIGINT"));
49
42
  process.once("SIGTERM", () => this.gracefulShutdown("SIGTERM"));
50
- console.log("[Aromix] Application started successfully", { totalBlocks: this.blocks.length });
51
43
  }
52
44
  async stop() {
53
45
  await this.stopAll("manual");
@@ -55,41 +47,29 @@ var App = class {
55
47
  async notifyError(err, phase, block) {
56
48
  const error = err instanceof Error ? err : new Error(String(err));
57
49
  if (block?.error && (phase === "start" || phase === "stop")) {
58
- try {
59
- await block.error(error, phase);
60
- } catch (handlerErr) {
61
- console.error(`[Aromix] Block "${block.name}" error handler itself threw`, handlerErr, { block: block.name, phase });
62
- }
50
+ await block.error(error, phase);
63
51
  }
64
52
  for (const handler of this.errorHandlers) {
65
- try {
66
- await handler(error, phase);
67
- } catch (handlerErr) {
68
- console.error("[Aromix] Global error handler threw", handlerErr, { phase });
69
- }
53
+ await handler(error, phase);
70
54
  }
71
55
  }
72
56
  async stopAll(reason) {
73
57
  if (this.isStopping) return true;
74
58
  this.isStopping = true;
75
- console.info("[Aromix] Stopping all blocks", { phase: "stop", signal: reason, totalBlocks: this.blocks.length });
76
59
  let allStoppedCleanly = true;
77
60
  for (let i = this.blocks.length - 1; i >= 0; i--) {
78
61
  const block = this.blocks[i];
79
62
  const startedAt = Date.now();
80
63
  try {
81
64
  await block.stop?.();
82
- console.log("[Aromix] Block stopped", { block: block.name, phase: "stop", durationMs: Date.now() - startedAt });
83
65
  } catch (err) {
84
66
  allStoppedCleanly = false;
85
- console.error("[Aromix] Block failed to stop", err, { block: block.name, phase: "stop" });
86
67
  await this.notifyError(err, "stop", block);
87
68
  }
88
69
  }
89
70
  return allStoppedCleanly;
90
71
  }
91
72
  async gracefulShutdown(signal) {
92
- console.info(`[Aromix] Received ${signal}. Starting graceful shutdown...`, { signal });
93
73
  const clean = await this.stopAll(signal);
94
74
  process.exit(clean ? 0 : 1);
95
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aromix/core",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "The Core Package For Aromix",
5
5
  "type": "module",
6
6
  "license": "MIT",