Project quality audit (#2758)

* Harden security, health checks, and dependency hygiene

Co-authored-by: Amruth Pillai <im.amruth@gmail.com>

* Finalize health and storage hardening adjustments

Co-authored-by: Amruth Pillai <im.amruth@gmail.com>

* remove use of [REDACTED]

* update dependencies

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
Amruth Pillai
2026-02-28 01:14:02 +01:00
committed by GitHub
parent c25c068d20
commit b7e4c86f4e
21 changed files with 1313 additions and 3328 deletions
+69
View File
@@ -0,0 +1,69 @@
type LogLevel = "debug" | "info" | "warn" | "error";
type LogContext = Record<string, unknown> & {
error?: unknown;
};
type SerializedError = {
name: string;
message: string;
stack?: string;
};
function serializeError(error: unknown): SerializedError | undefined {
if (!error) return undefined;
if (error instanceof Error) {
return {
name: error.name,
message: error.message,
stack: error.stack,
};
}
if (typeof error === "string") {
return {
name: "Error",
message: error,
};
}
if (typeof error === "object") {
return {
name: "Error",
message: JSON.stringify(error),
};
}
return {
name: "Error",
message: String(error),
};
}
function log(level: LogLevel, message: string, context: LogContext = {}) {
const { error, ...rest } = context;
const payload = {
ts: new Date().toISOString(),
level,
message,
...rest,
error: serializeError(error),
};
const json = JSON.stringify(payload);
if (level === "error") {
console.error(json);
return;
}
if (level === "warn") {
console.warn(json);
return;
}
console.log(json);
}
export const logger = {
debug: (message: string, context?: LogContext) => log("debug", message, context),
info: (message: string, context?: LogContext) => log("info", message, context),
warn: (message: string, context?: LogContext) => log("warn", message, context),
error: (message: string, context?: LogContext) => log("error", message, context),
};