Skip to content

Commit e1187f5

Browse files
committed
feat(api): provide dashboard summary repository
1 parent 7af82b0 commit e1187f5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

routes/_middleware.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ HtDataRepository<AppConfig> _createAppConfigRepository() {
148148
return HtDataRepository<AppConfig>(dataClient: client);
149149
}
150150

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+
151165
/// Middleware to asynchronously load and provide the AppConfig.
152166
Middleware _appConfigProviderMiddleware() {
153167
return (handler) {
@@ -174,6 +188,7 @@ Handler middleware(Handler handler) {
174188
final userContentPreferencesRepository =
175189
_createUserContentPreferencesRepository();
176190
final appConfigRepository = _createAppConfigRepository();
191+
final dashboardSummaryRepository = _createDashboardSummaryRepository();
177192

178193
const uuid = Uuid();
179194

@@ -286,6 +301,11 @@ Handler middleware(Handler handler) {
286301
),
287302
)
288303
.use(provider<HtDataRepository<AppConfig>>((_) => appConfigRepository))
304+
.use(
305+
provider<HtDataRepository<DashboardSummary>>(
306+
(_) => dashboardSummaryRepository,
307+
),
308+
)
289309
// ORDER: These MUST be provided BEFORE `authenticationProvider` and
290310
// any route handlers that perform authentication/authorization.
291311
// - `Uuid` is used by `AuthService` and `JwtAuthTokenService`.

0 commit comments

Comments
 (0)