Skip to content

Commit cd940ef

Browse files
committed
feat(api): load .env file directly within app dependencies
Modifies the `AppDependencies` singleton to use the `dotenv` package to load environment variables from the `.env` file at the start of its initialization sequence. This makes the application's configuration self-contained and resilient, removing the reliance on the `dart_frog_cli` to manage the environment.
1 parent 2ecb651 commit cd940ef

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/src/config/app_dependencies.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:dotenv/dotenv.dart' as dotenv;
34
import 'package:ht_api/src/config/database_connection.dart';
45
import 'package:ht_api/src/rbac/permission_service.dart';
56
import 'package:ht_api/src/services/auth_service.dart';
@@ -82,6 +83,10 @@ class AppDependencies {
8283
}
8384

8485
Future<void> _init() async {
86+
// 0. Load environment variables from .env file.
87+
dotenv.load();
88+
_log.info('Environment variables loaded from .env file.');
89+
8590
// 1. Establish Database Connection.
8691
await DatabaseConnectionManager.instance.init();
8792
final connection = await DatabaseConnectionManager.instance.connection;

0 commit comments

Comments
 (0)