feat: add pagination, sorting and filtering
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user