Skip to content

Commit

Permalink
feat: [app] - updated import paths and ensure save user in database
Browse files Browse the repository at this point in the history
  • Loading branch information
Christiangsn committed Mar 5, 2023
1 parent ffc0cab commit de86691
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/@application/contracts/app.contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface IHttpResponse<Data = any> {
statusCode: number
data: Data
}
/**
* Validation request data
* Create a new instances domain
* Verify incorrect parameters
*/
export interface IUseCasesAPP<DTO> {
run: (props: DTO) => Promise<IHttpResponse>
}
2 changes: 1 addition & 1 deletion src/@application/helpers/success.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type IHttpResponse } from '@infra/contracts/app.contracts'
import { type IHttpResponse } from '@application/contracts/app.contracts'

export const Success = <Data> (data: Data): IHttpResponse<Data> => ({
statusCode: 200,
Expand Down
20 changes: 11 additions & 9 deletions src/@application/useCases/user/signup/signUpUseCases.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { IpValueObject } from '@domain/user/valueObjects/termsObject/ipValueObject'
import { type ISignUpDTO } from './signupDTO'
import { DateCommonValueObject, EmailValueObject, PasswordValueObject, TermsValueObject, UserAggregate } from '@domain/user'
import { Result } from '@domain/shared/core'
/* eslint-disable */

import { DateCommonValueObject, EmailValueObject, IpValueObject, PasswordValueObject, TermsValueObject, UserAggregate } from '@domain/user'
import { type IUserRepositoryContract } from '@domain/contracts/repositories/userRepository.contract'
import { useCases } from '@application/useCases/default'
import { type IHttpResponse } from '@application/contracts/app.contracts'
import { BadRequest } from '@application/helpers/badRequest'
import { Success } from '@application/helpers/success'
import { useCases } from '@application/useCases/default'
import { Result } from '@domain/shared/core'

import { type ISignUpDTO } from './signupDTO'

import { BadRequest, Success } from '@application/helpers'

/**
* @event
Expand Down Expand Up @@ -52,7 +54,7 @@ export class SignupUseCases extends useCases<ISignUpDTO> {
if (termsOrError.isFailure) return BadRequest(termsOrError.error.toString())

const password = passwordOrError.getResult()
await password.encryptPassword()
void await password.encryptPassword()
// Validar o usuário agregado e retornar erro caso ocorra um erro
const userOrError: Result<UserAggregate> = UserAggregate.create({
email: emailOrError.getResult(),
Expand All @@ -67,7 +69,7 @@ export class SignupUseCases extends useCases<ISignUpDTO> {

// Salvar usuario
const user = userOrError.getResult()
await this.userRepository.save(user)
void await this.userRepository.save(user)

return Success(null)
}
Expand Down

0 comments on commit de86691

Please sign in to comment.