Files
Epicnabbo-Catalogus-Updated…/src/lib/admin-helpers.ts
T
openhands 17847545dd 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
2026-07-26 20:28:11 +02:00

34 lines
944 B
TypeScript

import type { ListParams } from "@/types/common";
export const PER_PAGE_OPTIONS = [10, 20, 50] as const;
const DEFAULT_PER_PAGE = 20;
export function parseListParams(searchParams: URLSearchParams): ListParams {
const search = searchParams.get("search") || "";
const perPage = Math.min(
Math.max(
parseInt(searchParams.get("perPage") || String(DEFAULT_PER_PAGE), 10),
1,
),
100,
);
const page = Math.max(parseInt(searchParams.get("page") || "1", 10), 1);
const sort = searchParams.get("sort") || undefined;
const order = (searchParams.get("order") === "asc" ? "asc" : "desc") as
| "asc"
| "desc";
return { search, perPage, page, sort, order };
}
export function calcPagination(total: number, page: number, perPage: number) {
const lastPage = Math.max(Math.ceil(total / perPage), 1);
return {
total,
page: Math.min(page, lastPage),
perPage,
lastPage,
offset: (Math.min(page, lastPage) - 1) * perPage,
};
}