diff --git a/frontend/src/lib/container.ts b/frontend/src/lib/container.ts new file mode 100644 index 0000000..2431825 --- /dev/null +++ b/frontend/src/lib/container.ts @@ -0,0 +1,73 @@ +import type { AuthApiService } from '$lib/auth/adapter/gateway/authApiService'; +import { AuthRepositoryImpl } from '$lib/auth/adapter/gateway/authRepositoryImpl'; +import type { AuthBloc } from '$lib/auth/adapter/presenter/authBloc'; +import type { AuthRepository } from '$lib/auth/application/gateway/authRepository'; +import { GetCurrentUserUseCase } from '$lib/auth/application/useCase/getCurrentUserUseCase'; +import { AuthApiServiceImpl } from '$lib/auth/framework/api/authApiServiceImpl'; +import type { ImageApiService } from '$lib/image/adapter/gateway/imageApiService'; +import { ImageRepositoryImpl } from '$lib/image/adapter/gateway/imageRepositoryImpl'; +import type { ImageBloc } from '$lib/image/adapter/presenter/imageBloc'; +import type { ImageRepository } from '$lib/image/application/gateway/imageRepository'; +import type { UploadImageUseCase } from '$lib/image/application/useCase/uploadImageUseCase'; +import { ImageApiServiceImpl } from '$lib/image/framework/api/imageApiServiceImpl'; +import type { PostApiService } from '$lib/post/adapter/gateway/postApiService'; +import { PostRepositoryImpl } from '$lib/post/adapter/gateway/postRepositoryImpl'; +import type { PostBloc } from '$lib/post/adapter/presenter/postBloc'; +import type { PostListBloc } from '$lib/post/adapter/presenter/postListBloc'; +import type { PostRepository } from '$lib/post/application/gateway/postRepository'; +import { GetAllPostsUseCase } from '$lib/post/application/useCase/getAllPostsUseCase'; +import { GetPostUseCase } from '$lib/post/application/useCase/getPostUseCase'; +import { PostApiServiceImpl } from '$lib/post/framework/api/postApiServiceImpl'; + +export class Container { + private fetchFn: typeof fetch; + + private _authApiService?: AuthApiService; + private _imageApiService?: ImageApiService; + private _postApiService?: PostApiService; + + private _authRepository?: AuthRepository; + private _imageRepository?: ImageRepository; + private _postRepository?: PostRepository; + + private _getCurrentUserUseCase?: GetCurrentUserUseCase; + private _uploadImageUseCase?: UploadImageUseCase; + private _getAllPostUseCase?: GetAllPostsUseCase; + private _getPostUseCase?: GetPostUseCase; + + constructor(fetchFn: typeof fetch) { + this.fetchFn = fetchFn; + } + + private get authApiService(): AuthApiService { + this._authApiService ??= new AuthApiServiceImpl(this.fetchFn); + return this._authApiService; + } + + private get imageApiService(): ImageApiService { + this._imageApiService ??= new ImageApiServiceImpl(this.fetchFn); + return this._imageApiService; + } + + private get postApiService(): PostApiService { + this._postApiService ??= new PostApiServiceImpl(this.fetchFn); + return this._postApiService; + } + + private get authRepository(): AuthRepository { + this._authRepository ??= new AuthRepositoryImpl(this.authApiService); + return this._authRepository; + } + + private get imageRepository(): ImageRepository { + this._imageRepository ??= new ImageRepositoryImpl(this.imageApiService); + return this._imageRepository; + } + + private get postRepository(): PostRepository { + this._postRepository ??= new PostRepositoryImpl(this.postApiService); + return this._postRepository; + } +} + +class ApiService \ No newline at end of file diff --git a/frontend/src/lib/home/framework/ui/Motto.svelte b/frontend/src/lib/home/framework/ui/Motto.svelte index feb1f01..efcf59f 100644 --- a/frontend/src/lib/home/framework/ui/Motto.svelte +++ b/frontend/src/lib/home/framework/ui/Motto.svelte @@ -1,5 +1,5 @@