chore: remediate pygienium audit findings

Dead code: 77 verified-unused exports, files (BackArrow, MenuBars,
cookies.ts, db/create.ts, schemas/comment.ts, security-headers.ts) and
12 unused dependencies removed
Comments: ~370 RESTATE comments stripped across 53 files; 2 verbose
blocks tightened; dead commented-out config removed
Complexity: bulkUpsert extracted into 11 per-entity helpers (CCN 156->~10);
login formHandler split into 3 submitters (CCN 63->~5); account page render
split into 8 section components (CCN 40); updatePost SQL builder rebuilt;
assert*Owned consolidated behind generic assertOwnedBy
Defensive guards: 4 redundant rethrow/nullish guards removed
This commit is contained in:
2026-08-11 13:36:18 -04:00
parent 33ca9213f2
commit 898c891bd5
76 changed files with 1437 additions and 2600 deletions

View File

@@ -117,14 +117,11 @@ function scheduleAnalyticsFlush(): void {
*/
export async function logVisit(entry: AnalyticsEntry): Promise<void> {
try {
// Add to buffer
analyticsBuffer.entries.push(entry);
// Flush if batch size reached
if (analyticsBuffer.entries.length >= CACHE_CONFIG.ANALYTICS_BATCH_SIZE) {
await flushAnalyticsBuffer();
} else {
// Schedule periodic flush
scheduleAnalyticsFlush();
}
} catch (error) {
@@ -422,7 +419,6 @@ export async function getPerformanceStats(days: number = 30): Promise<{
}> {
const conn = ConnectionFactory();
// Get average metrics
const avgResult = await conn.execute({
sql: `SELECT
AVG(lcp) as avgLcp,
@@ -472,7 +468,6 @@ export async function getPerformanceStats(days: number = 30): Promise<{
args: []
});
// Get performance by path (only for non-API paths)
const byPathResult = await conn.execute({
sql: `SELECT
path,