-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
462 additions
and
125 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<h1>Data Source</h1> | ||
<p>Esta camada tem como responsabilidade o acesso a dados no lado do servidor, contendo códigos que modela e se comunica com um ou mais tipos de fonte de dados e tudo que está relacionado diretamente, como gerenciamento de estado por exemplo.</p> | ||
<blockquote> | ||
<p>Aqui encontraremos muitas implementações concretas cujos contratos foram definidos na camada de domínio.</p> | ||
</blockquote> | ||
<h2>Estrutura</h2> | ||
<pre><code class="language-sh">📂 src | ||
└── 📂 lib | ||
├── dtos | ||
├── entities | ||
├── facades | ||
├── providers | ||
├── repositories | ||
├── services | ||
└── providers.ts | ||
</code></pre> | ||
<h2>DTOs</h2> | ||
<h2>Entities</h2> | ||
<h2>Facades</h2> | ||
<h2>Providers</h2> | ||
<h2>Repositories</h2> | ||
<h2>Services</h2> | ||
<style> | ||
body { | ||
font-family: 'Segoe UI', sans-serif; | ||
} | ||
blockquote { | ||
margin-left: 1em; | ||
margin-top: 1em; | ||
padding: 0.06em 0.6em; | ||
background-color: #12e20b4a; | ||
border-style: solid; | ||
border-color: #12e20b; | ||
border-width: 0 0.2em 0.2em 0; | ||
border-radius: 0.3em; | ||
|
||
transition: margin 500ms ease-in-out, border 500ms ease-in-out; | ||
} | ||
blockquote:hover { | ||
margin-left: 0; | ||
margin-top: 0; | ||
border-width: 0 0.8em 0.8em 0; | ||
} | ||
</style> | ||
|
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Data Source | ||
|
||
Esta camada tem como responsabilidade o acesso a dados no lado do servidor, contendo códigos que modela e se comunica com um ou mais tipos de fonte de dados e tudo que está relacionado diretamente, como gerenciamento de estado por exemplo. | ||
|
||
> Aqui encontraremos muitas implementações concretas cujos contratos foram definidos na camada de domínio. | ||
## Estrutura | ||
|
||
```sh | ||
📂 src | ||
└── 📂 lib | ||
├── dtos | ||
├── entities | ||
├── facades | ||
├── providers | ||
├── repositories | ||
├── services | ||
└── providers.ts | ||
``` | ||
|
||
## DTOs | ||
|
||
## Entities | ||
|
||
## Facades | ||
|
||
## Providers | ||
|
||
## Repositories | ||
|
||
## Services |
67 changes: 0 additions & 67 deletions
67
packages/data-source-account/src/lib/data-source-account.providers.ts
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/data-source-account/src/lib/data-source-account.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 +1,3 @@ | ||
export * from './create-user'; | ||
export * from './sign-in'; | ||
export * from './sign-up'; |
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,11 +1,14 @@ | ||
import { IsString, MinLength } from 'class-validator'; | ||
import { SignIn } from '@platform/domain-account'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class SignInDto implements SignIn { | ||
@IsString() | ||
@ApiProperty() | ||
username: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@ApiProperty() | ||
password: string; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { IsEmail, IsString, MinLength } from 'class-validator'; | ||
import { SignUp } from '@platform/domain-account'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class SignUpDto implements SignUp { | ||
@IsString() | ||
@ApiProperty() | ||
firstName: string; | ||
|
||
@IsString() | ||
@ApiProperty() | ||
lastName: string; | ||
|
||
@IsEmail() | ||
@ApiProperty() | ||
email: string; | ||
|
||
@IsString() | ||
@ApiProperty() | ||
username: string; | ||
|
||
@IsString() | ||
@MinLength(6) | ||
@ApiProperty() | ||
password: string; | ||
|
||
phone?: string; | ||
|
||
photo?: string; | ||
} |
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,17 @@ | ||
import { SignInServerUseCase } from '@platform/domain-account'; | ||
import { SignInDto } from '../dtos'; | ||
import { SignInServerUseCase, SignUpServerUseCase } from '@platform/domain-account'; | ||
import { SignInDto, SignUpDto } from '../dtos'; | ||
|
||
export class AuthFacade { | ||
constructor(private readonly signInUseCase: SignInServerUseCase) {} | ||
constructor( | ||
private readonly signInUseCase: SignInServerUseCase, | ||
private readonly signUpUseCase: SignUpServerUseCase | ||
) {} | ||
|
||
signIn(data: SignInDto) { | ||
return this.signInUseCase.execute(data); | ||
} | ||
|
||
signUp(data: SignUpDto) { | ||
return this.signUpUseCase.execute(data); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
provideAuthServerFacade, | ||
provideCreateUserServerUseCase, | ||
provideCryptoService, | ||
provideFindUsersServerUseCase, | ||
provideSignInServerUseCase, | ||
provideSignUpServerUseCase, | ||
provideUserRepository, | ||
provideUserServerFacade, | ||
} from './providers/index'; | ||
import { UserRepositoryImpl } from './repositories'; | ||
import { Provider } from '@platform/util-shared'; | ||
import { CryptoServiceImpl } from './services'; | ||
|
||
export const dataSourceAccountProviders: Provider[] = [ | ||
provideUserRepository(UserRepositoryImpl), | ||
|
||
provideCreateUserServerUseCase(), | ||
provideFindUsersServerUseCase(), | ||
|
||
provideUserServerFacade(), | ||
|
||
provideCryptoService(CryptoServiceImpl), | ||
|
||
provideSignInServerUseCase(), | ||
provideSignUpServerUseCase(), | ||
|
||
provideAuthServerFacade(), | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
CreateUserServerUseCase, | ||
FindUsersServerUseCase, | ||
SignInServerUseCase, | ||
SignUpServerUseCase, | ||
} from '@platform/domain-account'; | ||
import { AuthFacade, UserFacade } from '../facades'; | ||
|
||
export function provideUserServerFacade() { | ||
return { | ||
provide: UserFacade, | ||
useFactory( | ||
createUser: CreateUserServerUseCase, | ||
findUsers: FindUsersServerUseCase | ||
) { | ||
return new UserFacade(createUser, findUsers); | ||
}, | ||
inject: [CreateUserServerUseCase, FindUsersServerUseCase], | ||
}; | ||
} | ||
|
||
export function provideAuthServerFacade() { | ||
return { | ||
provide: AuthFacade, | ||
useFactory(signIn: SignInServerUseCase, signUp: SignUpServerUseCase) { | ||
return new AuthFacade(signIn, signUp); | ||
}, | ||
inject: [SignInServerUseCase, SignUpServerUseCase], | ||
}; | ||
} |
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,2 +1,5 @@ | ||
export * from './crypto'; | ||
export * from './facade'; | ||
export * from './jwt'; | ||
export * from './repository'; | ||
export * from './use-case'; |
22 changes: 22 additions & 0 deletions
22
packages/data-source-account/src/lib/providers/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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { UserRepository } from '@platform/domain-account'; | ||
import { getRepositoryToken } from '@nestjs/typeorm'; | ||
import { Type } from '@platform/util-shared'; | ||
import { UserEntity } from '../entities'; | ||
import { Repository } from 'typeorm'; | ||
|
||
export function provideUserRepository(Repository: Type<UserRepository>) { | ||
return { | ||
provide: UserRepository, | ||
useFactory(repository: Repository<UserEntity>) { | ||
return new Repository(repository); | ||
}, | ||
inject: [getRepositoryToken(UserEntity)], | ||
}; | ||
} | ||
|
||
export function provideUserRepositoryTest(Repository: UserRepository) { | ||
return { | ||
provide: UserRepository, | ||
useValue: Repository, | ||
}; | ||
} |
Oops, something went wrong.