feat: topology, and improves handling

This commit is contained in:
2026-02-17 19:17:13 +07:00
parent e8dbefde43
commit d14f043e7c
145 changed files with 4213 additions and 2861 deletions
+28
View File
@@ -0,0 +1,28 @@
export function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
if (typeof error === "string") {
return error;
}
return String(error);
}
/** Returns age string like "3d", "12h", "5m" */
export function getAge(timestamp: Date | string | undefined): string {
if (!timestamp) return "unknown";
const now = new Date();
const created = new Date(timestamp);
const diff = now.getTime() - created.getTime();
const seconds = Math.floor(diff / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 0) return `${days}d`;
if (hours > 0) return `${hours}h`;
if (minutes > 0) return `${minutes}m`;
return `${seconds}s`;
}