-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from wandersonDeve/main
feat: set catch in db calls
- Loading branch information
Showing
55 changed files
with
676 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/modules/applications/repository/applications.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { EntityRepository, Repository } from 'typeorm'; | ||
import { ApplicationEntity } from '../../../database/entities/applications.entity'; | ||
import { handleError } from '../../../shared/utils/handle-error.util'; | ||
|
||
@EntityRepository(ApplicationEntity) | ||
export class ApplicationsRepository extends Repository<ApplicationEntity> { | ||
async saveApplication(data: any): Promise<ApplicationEntity> { | ||
return this.save(data); | ||
return this.save(data).catch(handleError); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ import { MailService } from './mail.service'; | |
pass: config.get('MAIL_PASSWORD'), | ||
}, | ||
tls: { | ||
rejectUnauthorized: false | ||
} | ||
rejectUnauthorized: false, | ||
}, | ||
}, | ||
defaults: { | ||
from: `no-reply <[email protected]>`, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { | ||
registerDecorator, | ||
ValidationArguments, | ||
ValidationOptions, | ||
ValidatorConstraint, | ||
ValidatorConstraintInterface, | ||
} from 'class-validator'; | ||
|
||
export function Match(property: string, validationOptions?: ValidationOptions) { | ||
return (object: any, propertyName: string) => { | ||
registerDecorator({ | ||
target: object.constructor, | ||
propertyName, | ||
options: validationOptions, | ||
constraints: [property], | ||
validator: MatchConstraint, | ||
}); | ||
}; | ||
registerDecorator, | ||
ValidationArguments, | ||
ValidationOptions, | ||
ValidatorConstraint, | ||
ValidatorConstraintInterface, | ||
} from 'class-validator'; | ||
|
||
export function Match(property: string, validationOptions?: ValidationOptions) { | ||
return (object: any, propertyName: string) => { | ||
registerDecorator({ | ||
target: object.constructor, | ||
propertyName, | ||
options: validationOptions, | ||
constraints: [property], | ||
validator: MatchConstraint, | ||
}); | ||
}; | ||
} | ||
|
||
@ValidatorConstraint({ name: 'Match' }) | ||
export class MatchConstraint implements ValidatorConstraintInterface { | ||
validate(value: any, args: ValidationArguments) { | ||
const [relatedPropertyName] = args.constraints; | ||
const relatedValue = (args.object as any)[relatedPropertyName]; | ||
return value === relatedValue; | ||
} | ||
|
||
@ValidatorConstraint({ name: 'Match' }) | ||
export class MatchConstraint implements ValidatorConstraintInterface { | ||
validate(value: any, args: ValidationArguments) { | ||
const [relatedPropertyName] = args.constraints; | ||
const relatedValue = (args.object as any)[relatedPropertyName]; | ||
return value === relatedValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { HttpStatus, applyDecorators } from "@nestjs/common"; | ||
import { ApiOperation, ApiResponse } from "@nestjs/swagger"; | ||
import { UserLoginResponseDto } from "src/modules/auth/dtos/user-login-response.dto"; | ||
import { BadRequestSwagger } from "../../bad-request.swagger"; | ||
import { HttpStatus, applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
import { UserLoginResponseDto } from 'src/modules/auth/dtos/user-login-response.dto'; | ||
import { BadRequestSwagger } from '../../bad-request.swagger'; | ||
|
||
export function LoginSwagger() { | ||
return applyDecorators( | ||
ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Exemplo do retorno de sucesso da rota', | ||
type: UserLoginResponseDto, | ||
}), | ||
ApiResponse({ | ||
status: HttpStatus.BAD_REQUEST, | ||
description: 'Modelo de erro', | ||
type: BadRequestSwagger, | ||
}), | ||
ApiOperation({ | ||
summary: 'Rota para fazer login na plataforma', | ||
}) | ||
) | ||
} | ||
return applyDecorators( | ||
ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Exemplo do retorno de sucesso da rota', | ||
type: UserLoginResponseDto, | ||
}), | ||
ApiResponse({ | ||
status: HttpStatus.BAD_REQUEST, | ||
description: 'Modelo de erro', | ||
type: BadRequestSwagger, | ||
}), | ||
ApiOperation({ | ||
summary: 'Rota para fazer login na plataforma', | ||
}), | ||
); | ||
} |
42 changes: 21 additions & 21 deletions
42
src/shared/Swagger/decorators/auth/user-logged.swagger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { HttpStatus, applyDecorators } from "@nestjs/common"; | ||
import { ApiOperation, ApiResponse } from "@nestjs/swagger"; | ||
import { LoggerUserType } from "src/modules/auth/types/logged-user.types"; | ||
import { UnauthorizedSwagger } from "../../unauthorized.swagger"; | ||
import { HttpStatus, applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
import { LoggerUserType } from 'src/modules/auth/types/logged-user.types'; | ||
import { UnauthorizedSwagger } from '../../unauthorized.swagger'; | ||
|
||
export function UserLoggedSwagger(){ | ||
return applyDecorators( | ||
ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Exemplo do retorno de sucesso da rota', | ||
type: LoggerUserType, | ||
}), | ||
ApiResponse({ | ||
status: HttpStatus.UNAUTHORIZED, | ||
description: 'Modelo de erro', | ||
type: UnauthorizedSwagger, | ||
}), | ||
ApiOperation({ | ||
summary: 'Retorna usuário logado', | ||
}) | ||
) | ||
} | ||
export function UserLoggedSwagger() { | ||
return applyDecorators( | ||
ApiResponse({ | ||
status: HttpStatus.OK, | ||
description: 'Exemplo do retorno de sucesso da rota', | ||
type: LoggerUserType, | ||
}), | ||
ApiResponse({ | ||
status: HttpStatus.UNAUTHORIZED, | ||
description: 'Modelo de erro', | ||
type: UnauthorizedSwagger, | ||
}), | ||
ApiOperation({ | ||
summary: 'Retorna usuário logado', | ||
}), | ||
); | ||
} |
16 changes: 8 additions & 8 deletions
16
src/shared/Swagger/decorators/comment/create-comment.swagger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { applyDecorators } from "@nestjs/common"; | ||
import { ApiOperation } from "@nestjs/swagger"; | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
|
||
export function CreateCommentSwagger() { | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Cadastrar um comentário.', | ||
}) | ||
) | ||
} | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Cadastrar um comentário.', | ||
}), | ||
); | ||
} |
16 changes: 8 additions & 8 deletions
16
src/shared/Swagger/decorators/comment/delete-commentary.swagger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { applyDecorators } from "@nestjs/common"; | ||
import { ApiOperation } from "@nestjs/swagger"; | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
|
||
export function DeleteCommentarySwagger() { | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Excluir um comentário por id.', | ||
}) | ||
) | ||
} | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Excluir um comentário por id.', | ||
}), | ||
); | ||
} |
16 changes: 8 additions & 8 deletions
16
src/shared/Swagger/decorators/comment/get-all-commentaries.swagger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { applyDecorators } from "@nestjs/common"; | ||
import { ApiOperation } from "@nestjs/swagger"; | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation } from '@nestjs/swagger'; | ||
|
||
export function GetAllCommentariesSwagger() { | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Encontrar todos os comentários.', | ||
}) | ||
) | ||
} | ||
return applyDecorators( | ||
ApiOperation({ | ||
summary: 'Encontrar todos os comentários.', | ||
}), | ||
); | ||
} |
Oops, something went wrong.