extract auth to lib

This commit is contained in:
2026-02-22 20:37:30 +01:00
parent db6813cab1
commit 9f86fe80d7
24 changed files with 2442 additions and 0 deletions

29
src/api/query.ts Normal file
View File

@@ -0,0 +1,29 @@
type BuildListQueryOptions = {
q?: string;
page?: number;
pageSize?: number;
sort?: string;
defaultSort: string;
};
export function buildListQuery({
q,
page = 1,
pageSize = 10,
sort,
defaultSort
}: BuildListQueryOptions): string {
const query = new URLSearchParams();
const normalizedQuery = q?.trim();
const normalizedSort = sort?.trim();
if (normalizedQuery) {
query.set('q', normalizedQuery);
}
query.set('page', String(page));
query.set('pageSize', String(pageSize));
query.set('sort', normalizedSort || defaultSort);
return query.toString();
}