diff --git a/src/config.ts b/src/config.ts index 57e1279..2dbc3d9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -41,13 +41,6 @@ export const AUTH_CONFIG = { REFRESH_COOKIE_MAX_AGE_SHORT: 60 * 60 * 24 * 7, // 7 days REFRESH_COOKIE_MAX_AGE_LONG: 60 * 60 * 24 * 90, // 90 days - // Legacy (keep for backwards compatibility during migration) - JWT_EXPIRY: "15m" as const, // Deprecated: use ACCESS_TOKEN_EXPIRY - JWT_EXPIRY_SHORT: "15m" as const, // Deprecated - SESSION_COOKIE_MAX_AGE: 60 * 60 * 24 * 7, // Deprecated - REMEMBER_ME_MAX_AGE: 60 * 60 * 24 * 90, // Deprecated - - // Security Settings REFRESH_TOKEN_ROTATION_ENABLED: true, // Enable token rotation MAX_ROTATION_COUNT: 100, // Max rotations before forcing re-login REFRESH_TOKEN_REUSE_WINDOW_MS: 5000, // 5s grace period for race conditions diff --git a/src/lib/comment-utils.ts b/src/lib/comment-utils.ts index 931d11d..6922da7 100644 --- a/src/lib/comment-utils.ts +++ b/src/lib/comment-utils.ts @@ -43,101 +43,6 @@ export function getCommentLevel( return level; } -/** - * @deprecated Server-side SQL sorting preferred for performance - * Logarithmic decay formula: score / log(age + 2) - */ -function calculateHotScore( - upvotes: number, - downvotes: number, - date: string -): number { - const score = upvotes - downvotes; - const now = new Date().getTime(); - const commentTime = new Date(date).getTime(); - const ageInHours = (now - commentTime) / (1000 * 60 * 60); - - return score / Math.log10(ageInHours + 2); -} - -/** - * @deprecated Server-side SQL sorting preferred for performance - */ -function getUpvoteCount( - commentID: number, - reactionMap: Map -): number { - const reactions = reactionMap.get(commentID) || []; - return reactions.filter( - (r) => r.type === "tears" || r.type === "heartEye" || r.type === "moneyEye" - ).length; -} - -/** - * @deprecated Server-side SQL sorting preferred for performance - */ -function getDownvoteCount( - commentID: number, - reactionMap: Map -): number { - const reactions = reactionMap.get(commentID) || []; - return reactions.filter( - (r) => r.type === "angry" || r.type === "sick" || r.type === "worried" - ).length; -} - -/** - * @deprecated Use server-side SQL sorting in routes/blog/[title]/index.tsx for better performance - */ -export function sortComments( - comments: Comment[], - mode: SortingMode, - reactionMap: Map -): Comment[] { - const sorted = [...comments]; - - switch (mode) { - case "newest": - return sorted.sort((a, b) => { - return new Date(b.date).getTime() - new Date(a.date).getTime(); - }); - - case "oldest": - return sorted.sort((a, b) => { - return new Date(a.date).getTime() - new Date(b.date).getTime(); - }); - - case "highest_rated": - return sorted.sort((a, b) => { - const upVotesA = getUpvoteCount(a.id, reactionMap); - const downVotesA = getDownvoteCount(a.id, reactionMap); - const upVotesB = getUpvoteCount(b.id, reactionMap); - const downVotesB = getDownvoteCount(b.id, reactionMap); - - const scoreA = upVotesA - downVotesA; - const scoreB = upVotesB - downVotesB; - - return scoreB - scoreA; - }); - - case "hot": - return sorted.sort((a, b) => { - const upVotesA = getUpvoteCount(a.id, reactionMap); - const downVotesA = getDownvoteCount(a.id, reactionMap); - const upVotesB = getUpvoteCount(b.id, reactionMap); - const downVotesB = getDownvoteCount(b.id, reactionMap); - - const hotScoreA = calculateHotScore(upVotesA, downVotesA, a.date); - const hotScoreB = calculateHotScore(upVotesB, downVotesB, b.date); - - return hotScoreB - hotScoreA; - }); - - default: - return sorted; - } -} - export function isValidCommentBody(body: string): boolean { return body.trim().length > 0 && body.length <= 10000; } diff --git a/src/server/api/schemas/blog.ts b/src/server/api/schemas/blog.ts index b01a8d2..76cfd75 100644 --- a/src/server/api/schemas/blog.ts +++ b/src/server/api/schemas/blog.ts @@ -6,15 +6,6 @@ import { z } from "zod"; * Schemas for post creation, updating, querying, and interactions */ -// ============================================================================ -// Post Category and Status -// ============================================================================ - -/** - * Post category enum (deprecated but kept for backward compatibility) - */ -export const postCategorySchema = z.enum(["blog", "project"]); - // ============================================================================ // Post Creation and Updates // ============================================================================