refactor: comprehensive codebase cleanup and architecture hardening
- Sprint 1 (Quick Wins): Remove dead analytics modules, fix 4 unresolved imports, replace 3 console.warn with logger, remove mock-crc import - Sprint 2 (Architecture): Create MascotChatRepository, AnalysisRepository, 3 Zod schemas (mascot-chat, analysis, voice), deduplicate error classes, move 3 SQL queries from routes to repository - Sprint 3 (Complexity): Replace 7 any types with proper interfaces, extract 6 helpers from prepareMediaMessage (CC 85 -> ~15) - Sprint 4 (Config): Remove 22 dead env vars from .env, add 30 missing vars to .env.example, standardize naming Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d0d9e1669e
commit
4becf0d6f1
@@ -21,11 +21,7 @@ export class ValidationError extends AppError {
|
||||
|
||||
export class NotFoundError extends AppError {
|
||||
constructor(resource: string, id?: string) {
|
||||
super(
|
||||
`${resource} not found${id ? `: ${id}` : ""}`,
|
||||
"NOT_FOUND",
|
||||
404,
|
||||
);
|
||||
super(`${resource} not found${id ? `: ${id}` : ""}`, "NOT_FOUND", 404);
|
||||
this.name = "NotFoundError";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export async function retryWithBackoff<T>(
|
||||
err.name = "AbortError";
|
||||
throw err;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
return await fn();
|
||||
} catch (err) {
|
||||
@@ -109,7 +109,7 @@ export async function retryWithBackoff<T>(
|
||||
minTimeout * factor ** attempt + Math.random() * 100,
|
||||
maxTimeout,
|
||||
);
|
||||
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
let timeoutId: NodeJS.Timeout;
|
||||
const onAbort = () => {
|
||||
@@ -119,12 +119,12 @@ export async function retryWithBackoff<T>(
|
||||
reject(abortErr);
|
||||
};
|
||||
if (signal?.aborted) return onAbort();
|
||||
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
if (signal) signal.removeEventListener("abort", onAbort);
|
||||
resolve();
|
||||
}, backoff);
|
||||
|
||||
|
||||
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user