feat : first step request tagging

This commit is contained in:
2025-08-04 15:31:34 +03:30
parent 7a3061d9a4
commit 2c10800ce7
27 changed files with 1044 additions and 168 deletions

View File

@@ -11,27 +11,17 @@ GetIt get diLiveStock => GetIt.instance;
Future<void> setupLiveStockDI() async {
diLiveStock.registerSingleton(DioErrorHandler());
final tokenService = Get.find<TokenStorageService>();
if (tokenService.baseurl.value == null) {
await tokenService.saveBaseUrl('https://api.dam.rasadyar.net/');
}
diLiveStock.registerLazySingleton<AuthRemoteDataSource>(
() => AuthRemoteDataSourceImp(diLiveStock.get<DioRemote>()),
);
diLiveStock.registerLazySingleton<AuthRepository>(
() => AuthRepositoryImp(diLiveStock.get<AuthRemoteDataSource>()),
);
// First register AppInterceptor with lazy callbacks
diLiveStock.registerLazySingleton<AppInterceptor>(
() => AppInterceptor(
() => AppInterceptor(
refreshTokenCallback: () async {
// Use lazy access to avoid circular dependency
final authRepository = diLiveStock.get<AuthRepository>();
final hasAuthenticated = await authRepository.hasAuthenticated();
if (hasAuthenticated) {
@@ -53,13 +43,26 @@ Future<void> setupLiveStockDI() async {
),
);
// Register DioRemote with the interceptor
diLiveStock.registerLazySingleton<DioRemote>(
() => DioRemote(
() => DioRemote(
baseUrl: tokenService.baseurl.value,
interceptors: diLiveStock.get<AppInterceptor>(),
// interceptors: diLiveStock.get<AppInterceptor>(),
),
);
// Initialize DioRemote
await diLiveStock.get<DioRemote>().init();
// Now register the data source and repository
diLiveStock.registerLazySingleton<AuthRemoteDataSource>(
() => AuthRemoteDataSourceImp(diLiveStock.get<DioRemote>()),
);
diLiveStock.registerLazySingleton<AuthRepository>(
() => AuthRepositoryImp(diLiveStock.get<AuthRemoteDataSource>()),
);
diLiveStock.registerLazySingleton<ImagePicker>(() => ImagePicker());
await diLiveStock.allReady();
}