Improvements: remove dead config, fix ESM, add URL validation, unify types, add missing logging
- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
This commit is contained in:
1 parent
b922f6d49f
commit
17847545dd
292 files changed
+69195
-67915
No files matched your search
@@ -5,8 +5,8 @@ import { prisma } from "@/lib/prisma";
|
||||
import {
|
||||
deletePage,
|
||||
getAncestors,
|
||||
getTreeFlat,
|
||||
getCatalogItemCounts,
|
||||
getTreeFlat,
|
||||
toInt,
|
||||
} from "@/lib/services/catalog-tree";
|
||||
import { rcon } from "@/lib/services/rcon";
|
||||
@@ -91,9 +91,7 @@ async function getChildren(
|
||||
): Promise<TreeNode[]> {
|
||||
// Roots in Habbo DBs are usually parent_id = -1, sometimes 0.
|
||||
const parentFilter =
|
||||
parentId <= 0
|
||||
? { OR: [{ parentId: -1 }, { parentId: 0 }] }
|
||||
: { parentId };
|
||||
parentId <= 0 ? { OR: [{ parentId: -1 }, { parentId: 0 }] } : { parentId };
|
||||
|
||||
if (isBc) {
|
||||
const pages = await prisma.catalogPagesBc.findMany({
|
||||
@@ -336,8 +334,7 @@ export const PATCH = withAdmin(
|
||||
catalog?: string;
|
||||
};
|
||||
const pageId = Number(body.pageId);
|
||||
const field =
|
||||
body.toggleField === "toggleVisible" ? "visible" : "enabled";
|
||||
const field = body.toggleField === "toggleVisible" ? "visible" : "enabled";
|
||||
if (!Number.isFinite(pageId) || pageId <= 0) {
|
||||
return apiError("Invalid pageId");
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ export const GET = withAdmin(
|
||||
const q = (request.nextUrl.searchParams.get("q") || "").trim();
|
||||
const limit = Math.min(
|
||||
Math.max(
|
||||
Number.parseInt(request.nextUrl.searchParams.get("limit") || "30", 10) ||
|
||||
30,
|
||||
Number.parseInt(
|
||||
request.nextUrl.searchParams.get("limit") || "30",
|
||||
10,
|
||||
) || 30,
|
||||
1,
|
||||
),
|
||||
50,
|
||||
|
||||
@@ -25,10 +25,13 @@ export const POST = withAdmin(
|
||||
: allSources;
|
||||
|
||||
if (sources.length === 0) {
|
||||
return new Response(sseEvent({ type: "error", message: "No sources configured" }), {
|
||||
status: 400,
|
||||
headers: { "Content-Type": "text/event-stream" },
|
||||
});
|
||||
return new Response(
|
||||
sseEvent({ type: "error", message: "No sources configured" }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { "Content-Type": "text/event-stream" },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const allItems: Array<{
|
||||
|
||||
+25
-26
@@ -1,8 +1,8 @@
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { apiJson } from "@/lib/api";
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { redisCache, apiCacheKey } from "@/lib/redis-cache";
|
||||
import { apiCacheKey, redisCache } from "@/lib/redis-cache";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -13,31 +13,30 @@ export const dynamic = "force-dynamic";
|
||||
*/
|
||||
export async function GET(_req: Request) {
|
||||
try {
|
||||
const data = await redisCache(
|
||||
apiCacheKey("home"),
|
||||
15,
|
||||
async () => {
|
||||
const [articles, online, hotelName] = await Promise.all([
|
||||
prisma.websiteArticles.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
slug: true,
|
||||
shortStory: true,
|
||||
image: true,
|
||||
createdAt: true,
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 4,
|
||||
}),
|
||||
prisma.user.count({ where: { online: "1" } }),
|
||||
resolveHotelName(),
|
||||
]);
|
||||
return { articles, online, hotelName };
|
||||
},
|
||||
);
|
||||
const data = await redisCache(apiCacheKey("home"), 15, async () => {
|
||||
const [articles, online, hotelName] = await Promise.all([
|
||||
prisma.websiteArticles.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
slug: true,
|
||||
shortStory: true,
|
||||
image: true,
|
||||
createdAt: true,
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 4,
|
||||
}),
|
||||
prisma.user.count({ where: { online: "1" } }),
|
||||
resolveHotelName(),
|
||||
]);
|
||||
return { articles, online, hotelName };
|
||||
});
|
||||
return apiJson(data);
|
||||
} catch {
|
||||
return apiJson({ articles: [], online: 0, hotelName: FALLBACK_HOTEL_NAME }, { status: 200 });
|
||||
return apiJson(
|
||||
{ articles: [], online: 0, hotelName: FALLBACK_HOTEL_NAME },
|
||||
{ status: 200 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,8 @@ export async function GET(request: NextRequest) {
|
||||
const res = await fetch(upstreamUrl, {
|
||||
signal: AbortSignal.timeout(UPSTREAM_TIMEOUT_MS),
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { env } from "@/env";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { sessionUserId } from "@/lib/auth/session-user";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { logServerError } from "@/lib/server-log";
|
||||
import {
|
||||
type CaptureResult,
|
||||
captureOrder,
|
||||
creditsPerUnit,
|
||||
isPayPalConfigured,
|
||||
type CaptureResult,
|
||||
} from "@/lib/services/paypal";
|
||||
import {
|
||||
type AuthorizedTopup,
|
||||
authorizeTopupCapture,
|
||||
claimTopupDelivery,
|
||||
TopupCaptureError,
|
||||
type AuthorizedTopup,
|
||||
} from "@/lib/services/paypal-topup";
|
||||
import { rcon } from "@/lib/services/rcon";
|
||||
import { sendCurrency } from "@/lib/services/send-currency";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
|
||||
import { env } from "@/env";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { sessionUserId } from "@/lib/auth/session-user";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import {
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
PAYPAL_CURRENCY,
|
||||
} from "@/lib/services/paypal";
|
||||
import { recordCreatedTopup } from "@/lib/services/paypal-topup";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ function truthy(value: string | null | undefined): boolean {
|
||||
|
||||
export async function GET(_req: Request) {
|
||||
try {
|
||||
const values = await siteSettings.getMany(["radio_auto_play", "radio_autoplay"]);
|
||||
const values = await siteSettings.getMany([
|
||||
"radio_auto_play",
|
||||
"radio_autoplay",
|
||||
]);
|
||||
const autoplay = truthy(values.radio_auto_play ?? values.radio_autoplay);
|
||||
return apiJson({ autoplay });
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user