-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth && user): implementing get profile endpoint
- Loading branch information
1 parent
dd8946e
commit ac6ace4
Showing
21 changed files
with
439 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,5 @@ coverage/ | |
.env | ||
postgres-data | ||
|
||
.vscode | ||
.idea | ||
.eslintcache |
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,62 @@ | ||
{ | ||
// Place your backend-template workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | ||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | ||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | ||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | ||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | ||
// Placeholders with the same ids are connected. | ||
// Example: | ||
// "Print to console": { | ||
// "scope": "javascript,typescript", | ||
// "prefix": "log", | ||
// "body": [ | ||
// "console.log('$1');", | ||
// "$2" | ||
// ], | ||
// "description": "Log output to console" | ||
// } | ||
|
||
"region": { | ||
"prefix": "region", | ||
"body": ["//#region $1", "", "$0", "", "//#endregion"] | ||
}, | ||
"entity": { | ||
"prefix": "entity", | ||
"body": [ | ||
"export interface $1EntityProps {", | ||
"}", | ||
"", | ||
"export type $1EntityCreateProps = Replace<", | ||
" $1EntityProps,", | ||
" {", | ||
" }", | ||
">;", | ||
"", | ||
"export class $1Entity extends BaseEntity<$1EntityProps> {", | ||
" private constructor(", | ||
" props: $1EntityProps,", | ||
" baseEntityProps?: BaseEntityProps,", | ||
" ) {", | ||
" super(props, baseEntityProps);", | ||
" Object.freeze(this);", | ||
" }", | ||
"", | ||
" static create(", | ||
" {}: $1EntityCreateProps,", | ||
" baseEntityProps?: BaseEntityProps,", | ||
" ): Either<InvalidEmailError | InvalidNameError, $1Entity> {", | ||
"", | ||
"", | ||
" return new Right(", | ||
" new $1Entity(", | ||
" {", | ||
" },", | ||
" baseEntityProps,", | ||
" ),", | ||
" );", | ||
" }", | ||
"", | ||
"}" | ||
] | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/modules/auth/domain/entities/request-user.entity.test.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,20 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { Right } from '@shared/helpers/either'; | ||
import { RequestUserEntity } from './request-user.entity'; | ||
|
||
describe('RequestUserEntity', () => { | ||
it('should be able to instantiate', () => { | ||
const id = faker.string.uuid(); | ||
const email = faker.internet.email(); | ||
|
||
const entity = RequestUserEntity.create({ | ||
id, | ||
email, | ||
}); | ||
|
||
expect(entity).toBeInstanceOf(Right); | ||
|
||
expect((entity.value as RequestUserEntity).id).toBe(id); | ||
expect((entity.value as RequestUserEntity).email).toBe(email); | ||
}); | ||
}); |
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,33 @@ | ||
import { Either, Right } from '@shared/helpers/either'; | ||
import { UUID } from 'crypto'; | ||
|
||
export interface RequestUserEntityProps { | ||
id: UUID; | ||
email: string; | ||
} | ||
|
||
export type RequestUserEntityCreateProps = RequestUserEntityProps; | ||
|
||
export class RequestUserEntity { | ||
private constructor(props: RequestUserEntityProps) { | ||
this.props = props; | ||
Object.freeze(this); | ||
} | ||
|
||
static create({ | ||
id, | ||
email, | ||
}: RequestUserEntityCreateProps): Either<Error, RequestUserEntity> { | ||
return new Right(new RequestUserEntity({ id, email })); | ||
} | ||
|
||
private props: RequestUserEntityProps; | ||
|
||
get id(): UUID { | ||
return this.props.id; | ||
} | ||
|
||
get email(): string { | ||
return this.props.email; | ||
} | ||
} |
Empty file.
23 changes: 23 additions & 0 deletions
23
src/modules/auth/infra/strategies/auth-jwt.strategy.test.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,23 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { JwtStrategy } from './auth-jwt.strategy'; | ||
|
||
describe('AuthJwtStrategy', () => { | ||
let strategy: JwtStrategy; | ||
|
||
beforeEach(() => { | ||
strategy = new JwtStrategy(); | ||
}); | ||
|
||
it('should return a request user entity', () => { | ||
const id = faker.number.int(); | ||
const email = faker.internet.email(); | ||
|
||
const result = strategy.validate({ | ||
sub: id, | ||
email, | ||
}); | ||
|
||
expect(result.id).toBe(id); | ||
expect(result.email).toBe(email); | ||
}); | ||
}); |
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
Oops, something went wrong.