Skip to content

Commit 5478b13

Browse files
authored
Update feed query DTO (#232)
### Description <!-- Provide a comprehensive description here about what your PR aims to solve. --> <!-- You may also add additional context --> - Make limit and offset optional - Parse string numeric values for limit and offset - Remove default values from DTO definition Fixes #231 --- ### PR Checklist <!-- Please do not remove this section --> <!-- Mark each item with an "x" ([ ] becomes [x]) --> - [x] Read the Developer's Guide in [CONTRIBUTING.md](https://github.com/yamcodes/bedstack/blob/main/CONTRIBUTING.md) - [x] Use a concise title to represent the changes introduced in this PR - [x] Provide a detailed description of the changes introduced in this PR, and, if necessary, some screenshots - [x] Reference an issue or discussion where the feature or changes have been previously discussed - [x] Add a failing test that passes with the changes introduced in this PR, or explain why it's not feasible - [x] Add documentation for the feature or changes introduced in this PR to the docs; you can run them with `bun docs` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Article feed query parameters `limit` and `offset` are now optional, with default values automatically applied when omitted. This provides greater flexibility for querying articles and simplifies common use cases. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a6e6a1d commit 5478b13

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
import { type } from 'arktype';
2-
import {
3-
DEFAULT_LIMIT,
4-
DEFAULT_OFFSET,
5-
MAX_LIMIT,
6-
MIN_LIMIT,
7-
MIN_OFFSET,
8-
} from '@/shared/constants';
2+
import { MAX_LIMIT, MIN_LIMIT, MIN_OFFSET } from '@/shared/constants';
93

104
/**
115
* DTO for article feed query parameters.
126
* Uses offset-based pagination with the following constraints:
13-
* - limit: number of items per request (default: DEFAULT_LIMIT, min: MIN_LIMIT, max: MAX_LIMIT)
14-
* - offset: number of items to skip (default: DEFAULT_OFFSET, min: MIN_OFFSET)
7+
* - limit: number of items per request (min: MIN_LIMIT, max: MAX_LIMIT)
8+
* - offset: number of items to skip (min: MIN_OFFSET)
159
*/
1610
export const ArticleFeedQueryDto = type({
17-
limit: `${MIN_LIMIT} <= number.integer <= ${MAX_LIMIT} = ${DEFAULT_LIMIT}`,
18-
offset: `number.integer >= ${MIN_OFFSET} = ${DEFAULT_OFFSET}`,
11+
'limit?': `string.numeric.parse |> ${MIN_LIMIT} <= number.integer <= ${MAX_LIMIT}`,
12+
'offset?': `string.numeric.parse |> number.integer >= ${MIN_OFFSET}`,
1913
});
2014

2115
export type ArticleFeedQueryDto = typeof ArticleFeedQueryDto.infer;

0 commit comments

Comments
 (0)