1. Performance: 25 pages switched from force-dynamic to revalidate=300 (ISR); 2 pages (community, developers) now fully static (SSG) 2. DB indexes: Added @@index on foreign keys for WebsiteArticles, WebsiteArticleReactions, WebsiteArticleComments, WebsiteHelpCenterTickets, WebsiteShopArticles, RadioSongRequests, StaffActivities 3. SEO: Added robots.ts, sitemap.ts, canonical URLs, Open Graph + Twitter Card metadata on root layout and news articles 4. A11Y: Replaced <details>/<summary> dropdowns with accessible button-based NavDropdown (aria-expanded, aria-haspopup, role=menu). MobileNav now uses translated aria-label, aria-expanded, aria-controls, role=menu 5. Code quality: Added try/catch to updateArticle/deleteArticle; deleteArticle now uses prisma. for atomicity 6. CI/CD: Added GitHub Actions workflow (typecheck + test) 7. i18n: Added openMenu/closeMenu keys to all 6 locales 8. Observability: Health endpoint now checks SMTP reachability when configured 9. Loading states: Added loading.tsx for root, admin, and news sections 10. Word filter cache: Added 60s TTL auto-refresh instead of manual cache bust
This commit is contained in:
1 parent
10523e58ce
commit
8bcbc501ba
48 files changed
+337
-98
No files matched your search
@@ -25,14 +25,16 @@ const OPENAI_MODERATIONS_URL = "https://api.openai.com/v1/moderations";
|
||||
const OPENAI_TIMEOUT_MS = 5_000;
|
||||
|
||||
/**
|
||||
* In-process cache of the lowercased website_wordfilter words. Mirrors the
|
||||
* caching strategy in site-settings.ts: populated on first use, kept until
|
||||
* reloadWordFilter() is called after an admin edits the list.
|
||||
* In-process cache of the lowercased website_wordfilter words. Auto-refreshes
|
||||
* after WORD_FILTER_TTL_MS to pick up admin edits without manual cache bust.
|
||||
*/
|
||||
let wordFilterCache: string[] | null = null;
|
||||
let wordFilterLoadedAt = 0;
|
||||
const WORD_FILTER_TTL_MS = 60_000;
|
||||
|
||||
async function loadWordFilter(): Promise<string[]> {
|
||||
if (wordFilterCache === null) {
|
||||
const now = Date.now();
|
||||
if (wordFilterCache === null || now - wordFilterLoadedAt > WORD_FILTER_TTL_MS) {
|
||||
try {
|
||||
const rows = await prisma.websiteWordfilter.findMany({
|
||||
select: { word: true },
|
||||
@@ -40,6 +42,7 @@ async function loadWordFilter(): Promise<string[]> {
|
||||
wordFilterCache = rows
|
||||
.map((r) => r.word.trim().toLowerCase())
|
||||
.filter((w) => w.length > 0);
|
||||
wordFilterLoadedAt = now;
|
||||
} catch {
|
||||
// DB unavailable — return an empty filter WITHOUT caching, so the next
|
||||
// call retries. Fail-open: a missing blocklist must not block content.
|
||||
|
||||
Reference in new issue
Block a user