Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions apps/api/src/website/website.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ export class WebsiteController {
type: PaginatedWebsiteResponseDto,
})
@ApiInternalServerErrorResponse({
// This decorator is For OpenAPI/Swagger documentation
// This decorator is For OpenAPI/Swagger documentation.
description: 'This response type indicates an internal error.',
})
async getResults(@Query() query: FilterWebsiteDto) {
// Ensure pagination values are safe integers within expected bounds to
// prevent passing unsanitized user input downstream.
const safePage = Math.max(1, Math.floor(Number(query.page) || 1));
const safeLimit = Math.min(
100,
Math.max(1, Math.floor(Number(query.limit) || 10)),
);

const websites = await this.websiteService.paginatedFilter(query, {
page: query.page,
limit: query.limit,
page: safePage,
limit: safeLimit,
route: `/${WEBSITE_ROUTE_NAME}`,
});

return websites;
}

Expand All @@ -61,7 +70,7 @@ export class WebsiteController {
'This response indicated that there is no matching `target_url` in the database',
})
@ApiInternalServerErrorResponse({
// This decorator is For OpenAPI/Swagger documentation
// This decorator is For OpenAPI/Swagger documentation.
description: 'This response type indicates an internal error.',
})
async getResultByUrl(@Param('url') url: string) {
Expand Down
Loading