App constructor

App()

Initializes a new kronix application.

During initialization, the framework:

  1. Loads configuration from .env.
  2. Registers the Router, ExceptionHandler, and WebSocketHub into the global DI container.
  3. Sets up system health and readiness routes.

Implementation

App() {
  Config.load();
  di.singleton(_router);
  di.singleton<ExceptionHandler>(exceptionHandler);
  di.singleton(_wsHub);
  di.singleton<Storage>(LocalStorage(
    root: Config.get('STORAGE_ROOT', 'storage')!,
    baseUrl: Config.get('STORAGE_URL', '/storage')!,
  ));

  // Resolve Queue driver from config
  final queueDriverName = Config.get('QUEUE_DRIVER', 'memory')!;
  final QueueDriver driver = _resolveQueueDriver(queueDriverName);
  di.singleton<Queue>(Queue(driver: driver));

  _setupDefaultRoutes();
}