Skip to content

Commit ef0ea3d

Browse files
committed
feat: implement default query helpers
1 parent 911e20b commit ef0ea3d

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/modules/creator/creator.controller.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ import { parseCreatorSortOptions } from './creator.utils';
1212
import { safeIntParam } from '../../utils/query.utils';
1313
import { parsePublicQuery } from '../../utils/public-query-parse.utils';
1414
import {
15-
DEFAULT_PAGE,
16-
DEFAULT_PAGE_SIZE,
1715
MIN_PAGE_SIZE,
1816
MAX_PAGE_SIZE,
1917
} from '../../constants/pagination.constants';
18+
import { PUBLIC_PAGE_PAGINATION_DEFAULTS } from '../../utils/public-list-query-defaults';
2019

2120
const LegacyCreatorQuerySchema = z.object({
2221
page: safeIntParam({
23-
defaultValue: DEFAULT_PAGE,
22+
defaultValue: PUBLIC_PAGE_PAGINATION_DEFAULTS.page,
2423
min: MIN_PAGE_SIZE,
2524
max: Number.MAX_SAFE_INTEGER,
2625
label: 'Page',
2726
}),
2827
limit: safeIntParam({
29-
defaultValue: DEFAULT_PAGE_SIZE,
28+
defaultValue: PUBLIC_PAGE_PAGINATION_DEFAULTS.limit,
3029
min: MIN_PAGE_SIZE,
3130
max: MAX_PAGE_SIZE,
3231
label: 'Limit',

src/modules/creators/creators.schemas.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import {
55
} from './creators.sort';
66
import { safeIntParam } from '../../utils/query.utils';
77
import {
8-
DEFAULT_PAGE_SIZE,
9-
DEFAULT_OFFSET,
108
MIN_PAGE_SIZE,
119
MAX_PAGE_SIZE,
1210
} from '../../constants/pagination.constants';
11+
import { PUBLIC_OFFSET_PAGINATION_DEFAULTS } from '../../utils/public-list-query-defaults';
1312

1413
/**
1514
* Validation schema for creator list query parameters.
@@ -23,13 +22,13 @@ import {
2322
export const CreatorListQuerySchema = z.object({
2423
// Pagination
2524
limit: safeIntParam({
26-
defaultValue: DEFAULT_PAGE_SIZE,
25+
defaultValue: PUBLIC_OFFSET_PAGINATION_DEFAULTS.limit,
2726
min: MIN_PAGE_SIZE,
2827
max: MAX_PAGE_SIZE,
2928
label: 'Limit',
3029
}),
3130
offset: safeIntParam({
32-
defaultValue: DEFAULT_OFFSET,
31+
defaultValue: PUBLIC_OFFSET_PAGINATION_DEFAULTS.offset,
3332
min: 0,
3433
max: Number.MAX_SAFE_INTEGER,
3534
label: 'Offset',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
DEFAULT_OFFSET,
3+
DEFAULT_PAGE,
4+
DEFAULT_PAGE_SIZE,
5+
} from '../constants/pagination.constants';
6+
7+
/**
8+
* Shared default query values for offset-based public list endpoints.
9+
* Keeps defaults centralized without introducing validation behavior.
10+
*/
11+
export const PUBLIC_OFFSET_PAGINATION_DEFAULTS = {
12+
limit: DEFAULT_PAGE_SIZE,
13+
offset: DEFAULT_OFFSET,
14+
} as const;
15+
16+
/**
17+
* Shared default query values for page-based public list endpoints.
18+
* Keeps defaults centralized without introducing validation behavior.
19+
*/
20+
export const PUBLIC_PAGE_PAGINATION_DEFAULTS = {
21+
page: DEFAULT_PAGE,
22+
limit: DEFAULT_PAGE_SIZE,
23+
} as const;

0 commit comments

Comments
 (0)