@@ -5,6 +5,7 @@ import 'package:ht_api/src/registry/model_registry.dart';
5
5
import 'package:ht_api/src/services/auth_service.dart' ;
6
6
import 'package:ht_api/src/services/auth_token_service.dart' ;
7
7
import 'package:ht_api/src/services/default_user_preference_limit_service.dart' ;
8
+ import 'package:ht_api/src/services/dashboard_summary_service.dart' ;
8
9
import 'package:ht_api/src/services/jwt_auth_token_service.dart' ;
9
10
import 'package:ht_api/src/services/token_blacklist_service.dart' ;
10
11
import 'package:ht_api/src/services/user_preference_limit_service.dart' ;
@@ -148,20 +149,6 @@ HtDataRepository<AppConfig> _createAppConfigRepository() {
148
149
return HtDataRepository <AppConfig >(dataClient: client);
149
150
}
150
151
151
- HtDataRepository <DashboardSummary > _createDashboardSummaryRepository () {
152
- print ('Initializing DashboardSummary Repository...' );
153
- final initialData = [
154
- DashboardSummary .fromJson (dashboardSummaryFixtureData),
155
- ];
156
- final client = HtDataInMemory <DashboardSummary >(
157
- toJson: (i) => i.toJson (),
158
- getId: (i) => i.id,
159
- initialData: initialData,
160
- );
161
- print ('DashboardSummary Repository Initialized.' );
162
- return HtDataRepository <DashboardSummary >(dataClient: client);
163
- }
164
-
165
152
/// Middleware to asynchronously load and provide the AppConfig.
166
153
Middleware _appConfigProviderMiddleware () {
167
154
return (handler) {
@@ -188,7 +175,14 @@ Handler middleware(Handler handler) {
188
175
final userContentPreferencesRepository =
189
176
_createUserContentPreferencesRepository ();
190
177
final appConfigRepository = _createAppConfigRepository ();
191
- final dashboardSummaryRepository = _createDashboardSummaryRepository ();
178
+
179
+ // Instantiate the new DashboardSummaryService with its dependencies
180
+ final dashboardSummaryService = DashboardSummaryService (
181
+ headlineRepository: headlineRepository,
182
+ categoryRepository: categoryRepository,
183
+ sourceRepository: sourceRepository,
184
+ );
185
+ print ('[MiddlewareSetup] DashboardSummaryService instantiated.' );
192
186
193
187
const uuid = Uuid ();
194
188
@@ -301,11 +295,6 @@ Handler middleware(Handler handler) {
301
295
),
302
296
)
303
297
.use (provider <HtDataRepository <AppConfig >>((_) => appConfigRepository))
304
- .use (
305
- provider <HtDataRepository <DashboardSummary >>(
306
- (_) => dashboardSummaryRepository,
307
- ),
308
- )
309
298
// ORDER: These MUST be provided BEFORE `authenticationProvider` and
310
299
// any route handlers that perform authentication/authorization.
311
300
// - `Uuid` is used by `AuthService` and `JwtAuthTokenService`.
@@ -328,6 +317,7 @@ Handler middleware(Handler handler) {
328
317
.use (
329
318
provider <AuthService >((_) => authService),
330
319
) // Reads other services/repos
320
+ .use (provider <DashboardSummaryService >((_) => dashboardSummaryService))
331
321
// --- 5. RBAC Service Provider ---
332
322
// PURPOSE: Provides the PermissionService for authorization checks.
333
323
// ORDER: Must be provided before any middleware or handlers that use it
0 commit comments