remove deprecated code
This commit is contained in:
@@ -41,13 +41,6 @@ export const AUTH_CONFIG = {
|
|||||||
REFRESH_COOKIE_MAX_AGE_SHORT: 60 * 60 * 24 * 7, // 7 days
|
REFRESH_COOKIE_MAX_AGE_SHORT: 60 * 60 * 24 * 7, // 7 days
|
||||||
REFRESH_COOKIE_MAX_AGE_LONG: 60 * 60 * 24 * 90, // 90 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
|
REFRESH_TOKEN_ROTATION_ENABLED: true, // Enable token rotation
|
||||||
MAX_ROTATION_COUNT: 100, // Max rotations before forcing re-login
|
MAX_ROTATION_COUNT: 100, // Max rotations before forcing re-login
|
||||||
REFRESH_TOKEN_REUSE_WINDOW_MS: 5000, // 5s grace period for race conditions
|
REFRESH_TOKEN_REUSE_WINDOW_MS: 5000, // 5s grace period for race conditions
|
||||||
|
|||||||
@@ -43,101 +43,6 @@ export function getCommentLevel(
|
|||||||
return level;
|
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, CommentReaction[]>
|
|
||||||
): 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, CommentReaction[]>
|
|
||||||
): 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<number, CommentReaction[]>
|
|
||||||
): 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 {
|
export function isValidCommentBody(body: string): boolean {
|
||||||
return body.trim().length > 0 && body.length <= 10000;
|
return body.trim().length > 0 && body.length <= 10000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,6 @@ import { z } from "zod";
|
|||||||
* Schemas for post creation, updating, querying, and interactions
|
* 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
|
// Post Creation and Updates
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user