feat: add pagination, sorting and filtering

This commit is contained in:
2026-06-07 12:58:38 +03:30
parent 28c1a4831e
commit d1fecf62ad
19 changed files with 389 additions and 176 deletions
@@ -1,11 +1,12 @@
import { HashingProvider } from '@/common/modules/hashing/providers/hashing.provider';
import { Injectable, RequestTimeoutException } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { I18nService } from 'nestjs-i18n';
import { User } from '../entities/user.entity';
import { UpdateProfileDTO } from '../dto/update-profile.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { AppResponse } from '@/common/responses';
import { AppTimeoutException } from '@/common/exceptions/app-timeout.exception';
@Injectable()
export class UserProfileProvider {
@@ -59,10 +60,7 @@ export class UserProfileProvider {
try {
await this.userRepository.update(user.id, updateData);
} catch (err) {
throw new RequestTimeoutException('common.errors.requestTimeout', {
cause: err,
description: 'Error connecting to the database',
});
throw new AppTimeoutException(err);
}
return {
+5 -17
View File
@@ -1,13 +1,10 @@
import {
BadRequestException,
Injectable,
RequestTimeoutException,
} from '@nestjs/common';
import { BadRequestException, Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { User } from '../entities/user.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { UpdateProfileDTO } from '../dto/update-profile.dto';
import { UserProfileProvider } from './user-profile.provider';
import { AppTimeoutException } from '@/common/exceptions/app-timeout.exception';
@Injectable()
export class UsersService {
@@ -29,10 +26,7 @@ export class UsersService {
try {
user = await this.userRepository.findOneById(id);
} catch (err) {
throw new RequestTimeoutException('common.errors.requestTimeout', {
cause: err,
description: 'Error connecting to the database',
});
throw new AppTimeoutException(err);
}
if (!user) {
@@ -46,10 +40,7 @@ export class UsersService {
try {
return await this.userRepository.findOneBy({ phone });
} catch (err) {
throw new RequestTimeoutException('common.errors.requestTimeout', {
cause: err,
description: 'Error connecting to the database',
});
throw new AppTimeoutException(err);
}
}
@@ -59,10 +50,7 @@ export class UsersService {
try {
await this.userRepository.save(newUser);
} catch (err) {
throw new RequestTimeoutException('common.errors.requestTimeout', {
cause: err,
description: 'Error connecting to the database',
});
throw new AppTimeoutException(err);
}
return newUser;