Skip to content

Commit

Permalink
fix: check params empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jiho-kr committed Aug 29, 2024
1 parent 23e8058 commit 3a10636
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/interceptor/search-request.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export function SearchRequestInterceptor(crudOptions: CrudOptions, factoryOption
const req: Record<string, any> = context.switchToHttp().getRequest<Request>();
const searchOptions = crudOptions.routes?.[method] ?? {};
const customSearchRequestOptions: CustomSearchRequestOptions = req[CUSTOM_REQUEST_OPTIONS];
const paginationType = (searchOptions.paginationType ?? CRUD_POLICY[method].default.paginationType) as PaginationType;
const pagination = PaginationHelper.getPaginationRequest(paginationType, req.body);
const isNextPage = PaginationHelper.isNextPage(pagination);

if (req.params) {
if (Object.keys(req.params ?? {}).length > 0 && !isNextPage) {
const paramsCondition = Object.entries(req.params).reduce(
(queryFilter, [key, operand]) => ({ ...queryFilter, [key]: { operator: '=', operand } }),
{},
Expand All @@ -51,10 +54,6 @@ export function SearchRequestInterceptor(crudOptions: CrudOptions, factoryOption
}
}

const paginationType = (searchOptions.paginationType ?? CRUD_POLICY[method].default.paginationType) as PaginationType;
const pagination = PaginationHelper.getPaginationRequest(paginationType, req.body);
const isNextPage = PaginationHelper.isNextPage(pagination);

const requestSearchDto = await (async () => {
if (isNextPage) {
const isQueryValid = pagination.setQuery(pagination.query);
Expand Down

0 comments on commit 3a10636

Please sign in to comment.