desloppify: code health overhaul plus abuse hardening (140 green, strict 87.2)
Build & Push / Lint & Build (pull_request) Failing after 52s
Build & Push / Build & Push Image (pull_request) Skipped
Build & Push / Trigger Deploy (pull_request) Skipped

Honest baseline after removing 45 gaming suppressions. Structural: lib/game plus root hooks extraction, CORS origin echo, DEV_ORIGINS layering. Fixes: error-cause binding, discord 5xx split, null-cache guard, co-located tests, rejecting-fetch coverage, naming and typing cleanup, socket controller, cache bound, cascade helpers, latch resets. Hardening: per-IP rate limit on API routes, deterministic-miss UX, retry cooldown plus cap. Suite 140 green, build plus lint clean.
This commit is contained in:
fristy committed 2026-09-11 23:54:59 +03:00
1 parent 7d6d31265b
commit 864b9226fc
78 files changed
+4908 -1430

No files matched your search

+2 -1
View File
@@ -49,11 +49,12 @@
"loadError": "Spieldaten konnten nicht geladen werden.",
"retry": "Erneut versuchen",
"partialFail": "Einige Daten konnten nicht geladen werden.",
"noGameData": "Für diese App wurden keine Spieldaten gefunden.",
"screenshots": "Screenshots",
"reviewsUnit": "Bewertungen",
"scrollBack": "Zurück",
"scrollForward": "Weiter",
"totalReviews": "Bewertungen insgesamt",
"totalReviews": "Steam",
"steamdbRating": "SteamDB-Wertung",
"reviewScores": {
"overwhelminglyPositive": "Äußerst positiv",
+2 -1
View File
@@ -49,11 +49,12 @@
"loadError": "Couldn't load game info.",
"retry": "Retry",
"partialFail": "Some data failed to load.",
"noGameData": "No game data found for this app.",
"screenshots": "Screenshots",
"reviewsUnit": "reviews",
"scrollBack": "Back",
"scrollForward": "Forward",
"totalReviews": "Total Reviews",
"totalReviews": "Steam",
"steamdbRating": "SteamDB Rating",
"reviewScores": {
"overwhelminglyPositive": "Overwhelmingly Positive",
+2 -1
View File
@@ -49,11 +49,12 @@
"loadError": "Oyun bilgileri yüklenemedi.",
"retry": "Tekrar Dene",
"partialFail": "Bazı veriler yüklenemedi.",
"noGameData": "Bu uygulama için oyun verisi bulunamadı.",
"screenshots": "Görseller",
"reviewsUnit": "değerlendirme",
"scrollBack": "Geri",
"scrollForward": "İleri",
"totalReviews": "Toplam Değerlendirme",
"totalReviews": "Steam",
"steamdbRating": "SteamDB Puanı",
"reviewScores": {
"overwhelminglyPositive": "Son Derece Olumlu",
+27
View File
@@ -0,0 +1,27 @@
import { describe, expect, it } from "vitest";
import { getDictionary } from "@/lib/i18n/get-dictionary";
import { DEFAULT_LOCALE, matchLocale, type Locale } from "@/lib/i18n/locales";
describe("getDictionary", () => {
it("returns the requested locale", () => {
expect(getDictionary("de").discord.gameProfile).toBe("Spielprofil");
});
it("falls back to Turkish for unknown locales", () => {
expect(getDictionary(matchLocale("fr"))).toEqual(getDictionary("tr"));
});
it("keeps all locales structurally in sync", () => {
const shape = (locale: Locale): string => JSON.stringify(getDictionary(locale));
expect(Object.keys(JSON.parse(shape("en"))).sort()).toEqual(
Object.keys(JSON.parse(shape("tr"))).sort(),
);
expect(Object.keys(JSON.parse(shape("de"))).sort()).toEqual(
Object.keys(JSON.parse(shape("tr"))).sort(),
);
});
it("defaults to Turkish", () => {
expect(DEFAULT_LOCALE).toBe("tr");
});
});
+1 -1
View File
@@ -8,5 +8,5 @@ const dictionaries = { tr, en, de } as const;
export type Dictionary = typeof tr;
export function getDictionary(locale: Locale): Dictionary {
return dictionaries[locale] ?? dictionaries.tr;
return dictionaries[locale];
}
+25
View File
@@ -0,0 +1,25 @@
import { describe, expect, it, vi } from "vitest";
vi.mock("next/headers", () => ({
cookies: vi.fn(),
}));
import { cookies } from "next/headers";
import { getLocale } from "@/lib/i18n/get-locale";
describe("getLocale", () => {
it("returns the cookie locale when valid", async () => {
vi.mocked(cookies).mockResolvedValue({ get: () => ({ value: "de" }) } as never);
await expect(getLocale()).resolves.toBe("de");
});
it("falls back to default without a cookie", async () => {
vi.mocked(cookies).mockResolvedValue({ get: () => undefined } as never);
await expect(getLocale()).resolves.toBe("tr");
});
it("falls back on unknown values", async () => {
vi.mocked(cookies).mockResolvedValue({ get: () => ({ value: "fr" }) } as never);
await expect(getLocale()).resolves.toBe("tr");
});
});
+36
View File
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import { isLocale, matchLocale } from "@/lib/i18n/locales";
describe("isLocale", () => {
it("accepts supported locales", () => {
expect(isLocale("tr")).toBe(true);
expect(isLocale("en")).toBe(true);
expect(isLocale("de")).toBe(true);
});
it("rejects anything else", () => {
expect(isLocale("fr")).toBe(false);
expect(isLocale("")).toBe(false);
});
});
describe("matchLocale", () => {
it("defaults without a header", () => {
expect(matchLocale(null)).toBe("tr");
expect(matchLocale("")).toBe("tr");
});
it("matches primary ranges", () => {
expect(matchLocale("en-US,en;q=0.9")).toBe("en");
expect(matchLocale("de-DE,de;q=0.9,en;q=0.8")).toBe("de");
});
it("respects q-values", () => {
expect(matchLocale("en;q=0.5,tr;q=0.9")).toBe("tr");
});
it("falls back on unknown or wildcard ranges", () => {
expect(matchLocale("fr-FR,fr;q=0.9")).toBe("tr");
expect(matchLocale("*")).toBe("tr");
});
});
-16
View File
@@ -1,16 +0,0 @@
"use server";
import { cookies } from "next/headers";
import { LOCALE_COOKIE, isLocale, type Locale } from "./locales";
export async function setLocaleCookie(locale: Locale): Promise<void> {
if (!isLocale(locale)) {
return;
}
const store = await cookies();
store.set(LOCALE_COOKIE, locale, {
path: "/",
maxAge: 60 * 60 * 24 * 365,
sameSite: "lax",
});
}