Skip to content

Commit edb47ad

Browse files
committed
refactor(api): explicitly type service variables in server config
Improves code clarity and robustness in `server.dart` by explicitly typing service variables with their abstract base classes (e.g., `AuthTokenService`) instead of relying on type inference for their concrete implementations. This makes dependency contracts clearer and aligns with best practices.
1 parent ebf04d8 commit edb47ad

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

lib/src/config/server.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
6666

6767
// This middleware wraps the main handler. It awaits the completer's future,
6868
// effectively pausing the request until `initCompleter.complete()` is called.
69-
final gatedHandler = handler.use(
70-
(innerHandler) {
71-
return (context) async {
72-
await initCompleter.future;
73-
return innerHandler(context);
74-
};
75-
},
76-
);
69+
final gatedHandler = handler.use((innerHandler) {
70+
return (context) async {
71+
await initCompleter.future;
72+
return innerHandler(context);
73+
};
74+
});
7775

7876
// 1. Setup Logger
7977
Logger.root.level = Level.ALL;
@@ -152,10 +150,10 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
152150
);
153151
final userContentPreferencesRepository =
154152
_createRepository<UserContentPreferences>(
155-
tableName: 'user_content_preferences',
156-
fromJson: UserContentPreferences.fromJson,
157-
toJson: (p) => p.toJson(),
158-
);
153+
tableName: 'user_content_preferences',
154+
fromJson: UserContentPreferences.fromJson,
155+
toJson: (p) => p.toJson(),
156+
);
159157
final appConfigRepository = _createRepository<AppConfig>(
160158
tableName: 'app_config',
161159
fromJson: AppConfig.fromJson,
@@ -167,7 +165,7 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
167165
emailClient: HtEmailInMemoryClient(),
168166
);
169167
final tokenBlacklistService = InMemoryTokenBlacklistService();
170-
final authTokenService = JwtAuthTokenService(
168+
final AuthTokenService authTokenService = JwtAuthTokenService(
171169
userRepository: userRepository,
172170
blacklistService: tokenBlacklistService,
173171
uuidGenerator: const Uuid(),
@@ -183,15 +181,17 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
183181
userContentPreferencesRepository: userContentPreferencesRepository,
184182
uuidGenerator: const Uuid(),
185183
);
186-
final dashboardSummaryService = DashboardSummaryService(
187-
headlineRepository: headlineRepository,
188-
categoryRepository: categoryRepository,
189-
sourceRepository: sourceRepository,
190-
);
184+
final dashboardSummaryService =
185+
DashboardSummaryService(
186+
headlineRepository: headlineRepository,
187+
categoryRepository: categoryRepository,
188+
sourceRepository: sourceRepository,
189+
);
191190
const permissionService = PermissionService();
192-
final userPreferenceLimitService = DefaultUserPreferenceLimitService(
193-
appConfigRepository: appConfigRepository,
194-
);
191+
final UserPreferenceLimitService userPreferenceLimitService =
192+
DefaultUserPreferenceLimitService(
193+
appConfigRepository: appConfigRepository,
194+
);
195195

196196
// 6. Populate the DependencyContainer
197197
DependencyContainer.instance.init(
@@ -231,4 +231,4 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
231231
});
232232

233233
return server;
234-
}
234+
}

0 commit comments

Comments
 (0)