-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix merge conflict and fix issue with DI
- Loading branch information
Showing
43 changed files
with
417 additions
and
66 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,18 @@ | ||
import { inject, injectable } from "tsyringe"; | ||
import { type LoginRequestDto } from "@/modules/auth/application/dtos/request.dto"; | ||
import { type LoginResponseDto } from "@/modules/auth/application/dtos/response.dto"; | ||
import { LoginUsecase } from "@/modules/auth/application/usecases/loginUsecase"; | ||
import { type AuthClientPort } from "@/modules/auth/ports/primary/authClientPort"; | ||
import { TYPES } from "@/di/types"; | ||
|
||
@injectable() | ||
export class AuthClientAdapter implements AuthClientPort { | ||
constructor( | ||
@inject(TYPES.LoginUsecase) | ||
private readonly loginUsecase: LoginUsecase, | ||
) {} | ||
|
||
async login({ email, password }: LoginRequestDto): Promise<LoginResponseDto> { | ||
return await this.loginUsecase.execute({ email, password }); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { container } from "tsyringe"; | ||
import { TYPES } from "./types"; | ||
import { AuthApiAdapter } from "@/modules/auth/adapters/secondary/authApiAdapter"; | ||
import { AxiosAdapter } from "@/modules/restApi/adapters/secondary/AxiosAdapter"; | ||
import { AuthClientAdapter } from "@/app/(auth)/_adapters/authClientAdapter"; | ||
import { LoginUsecase } from "@/modules/auth/application/usecases/loginUsecase"; | ||
|
||
container.register(TYPES.RestApiPort, { useClass: AxiosAdapter }); | ||
container.register(TYPES.AuthApiPort, { useClass: AuthApiAdapter }); | ||
container.register(TYPES.LoginUsecase, { useClass: LoginUsecase }); | ||
container.register(TYPES.AuthClientAdapter, { useClass: AuthClientAdapter }); | ||
|
||
export default container; |
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,6 @@ | ||
import type { InjectionToken } from "tsyringe"; | ||
|
||
import container from "./config"; | ||
|
||
export const resolve = <T>(token: InjectionToken<T>): T => | ||
container.resolve(token); |
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,14 @@ | ||
export const TYPES = { | ||
/* Ports */ | ||
RestApiPort: Symbol.for("RestApiPort"), | ||
AuthClientPort: Symbol.for("AuthClientPort"), | ||
AuthApiPort: Symbol.for("AuthApiPort"), | ||
|
||
/* Adapters */ | ||
AxiosAdapter: Symbol.for("AxiosAdapter"), | ||
AuthClientAdapter: Symbol.for("AuthClientAdapter"), | ||
AuthApiAdapter: Symbol.for("AuthApiAdapter"), | ||
|
||
/* UseCases */ | ||
LoginUsecase: Symbol.for("LoginUsecase"), | ||
}; |
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,18 @@ | ||
import "reflect-metadata"; | ||
|
||
import { useMemo } from "react"; | ||
|
||
import { injectables } from "@/di/injectables"; | ||
|
||
const useInjection = () => { | ||
const injection = useMemo( | ||
() => ({ | ||
...injectables, | ||
}), | ||
[], | ||
); | ||
|
||
return injection; | ||
}; | ||
|
||
export default useInjection; |
Oops, something went wrong.