1- import 'dart:io' ;
1+ import 'dart:io' ;
22
33import 'package:dart_frog/dart_frog.dart' ;
44import 'package:ht_api/src/config/environment_config.dart' ;
55import 'package:ht_api/src/rbac/permission_service.dart' ;
66import 'package:ht_api/src/services/auth_service.dart' ;
77import 'package:ht_api/src/services/auth_token_service.dart' ;
88import 'package:ht_api/src/services/dashboard_summary_service.dart' ;
9+ import 'package:ht_api/src/services/database_seeding_service.dart' ;
910import 'package:ht_api/src/services/default_user_preference_limit_service.dart' ;
1011import 'package:ht_api/src/services/jwt_auth_token_service.dart' ;
11- import 'package:ht_api/src/services/database_seeding_service.dart' ;
1212import 'package:ht_api/src/services/token_blacklist_service.dart' ;
1313import 'package:ht_api/src/services/user_preference_limit_service.dart' ;
1414import 'package:ht_api/src/services/verification_code_storage_service.dart' ;
@@ -23,20 +23,20 @@ import 'package:postgres/postgres.dart';
2323import 'package:uuid/uuid.dart' ;
2424
2525/// Global logger instance.
26- final _log = Logger ('ht_api' );
26+ final _log = Logger ('ht_api' );
2727
2828/// Global PostgreSQL connection instance.
29- late final Connection _connection;
29+ late final Connection _connection;
3030
3131/// Creates a data repository for a given type [T] .
3232///
3333/// This helper function centralizes the creation of repositories,
3434/// ensuring they all use the same database connection and logger.
35- HtDataRepository <T > _createRepository <T >({
35+ HtDataRepository <T > _createRepository <T >({
3636 required String tableName,
3737 required FromJson <T > fromJson,
3838 required ToJson <T > toJson,
39- }) {
39+ }) {
4040 return HtDataRepository <T >(
4141 dataClient: HtDataPostgresClient <T >(
4242 connection: _connection,
@@ -46,7 +46,7 @@ import 'package:uuid/uuid.dart';
4646 log: _log,
4747 ),
4848 );
49- }
49+ }
5050
5151/// The main entry point for the server.
5252///
@@ -98,7 +98,10 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
9898 // `ON CONFLICT DO NOTHING`), so it's safe to run every time. This ensures
9999 // the database is always in a valid state, especially for first-time setup
100100 // in any environment.
101- final seedingService = DatabaseSeedingService (connection: _connection, log: _log);
101+ final seedingService = DatabaseSeedingService (
102+ connection: _connection,
103+ log: _log,
104+ );
102105 await seedingService.createTables ();
103106 await seedingService.seedGlobalFixtureData ();
104107 await seedingService.seedInitialAdminAndConfig ();
@@ -136,10 +139,10 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
136139 );
137140 final userContentPreferencesRepository =
138141 _createRepository <UserContentPreferences >(
139- tableName: 'user_content_preferences' ,
140- fromJson: UserContentPreferences .fromJson,
141- toJson: (p) => p.toJson (),
142- );
142+ tableName: 'user_content_preferences' ,
143+ fromJson: UserContentPreferences .fromJson,
144+ toJson: (p) => p.toJson (),
145+ );
143146 final appConfigRepository = _createRepository <AppConfig >(
144147 tableName: 'app_config' ,
145148 fromJson: AppConfig .fromJson,
@@ -212,17 +215,11 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
212215 .use (provider <DashboardSummaryService >((_) => dashboardSummaryService))
213216 .use (provider <PermissionService >((_) => permissionService))
214217 .use (
215- provider <UserPreferenceLimitService >(
216- (_) => userPreferenceLimitService,
217- ),
218+ provider <UserPreferenceLimitService >((_) => userPreferenceLimitService),
218219 );
219220
220221 // 7. Start the server
221- final server = await serve (
222- finalHandler,
223- ip,
224- port,
225- );
222+ final server = await serve (finalHandler, ip, port);
226223 _log.info ('Server listening on port ${server .port }' );
227224
228225 // 8. Handle graceful shutdown
@@ -236,4 +233,4 @@ Future<HttpServer> run(Handler handler, InternetAddress ip, int port) async {
236233 });
237234
238235 return server;
239- }
236+ }
0 commit comments