Skip to content

Deep Dive: Application

Technical reference for AbstractApplication and BaseApplication - the foundation classes for every Ignis application.

Files:

  • packages/core/src/base/applications/abstract.ts
  • packages/core/src/base/applications/base.ts

Quick Reference

ClassPurposeKey Methods
AbstractApplicationBase class with lifecycle managementpreConfigure(), postConfigure(), validateEnvs()
BaseApplicationConcrete implementation with resource registrationcomponent(), controller(), service(), repository(), dataSource()

AbstractApplication

Base class responsible for core lifecycle and server management.

Key Features

FeatureDescription
Hono InstanceCreates and holds the OpenAPIHono instance (underlying web server)
Runtime DetectionAuto-detects Bun or Node.js and uses appropriate server implementation
Core BindingsRegisters essential services (CoreBindings.APPLICATION_INSTANCE, CoreBindings.APPLICATION_SERVER)
Lifecycle ManagementDefines abstract methods (preConfigure, postConfigure, setupMiddlewares)
Environment ValidationValidates all required APP_ENV_* environment variables

BaseApplication

Extends AbstractApplication with concrete lifecycle implementations and resource registration.

Resource Registration Methods

BaseApplication provides a set of convenient methods for registering your application's building blocks. These methods bind the provided classes to the DI container with conventional keys.

MethodDI Binding Key Convention
component(MyComponent, opts?)components.MyComponent (default) or custom key via opts.binding
controller(MyController, opts?)controllers.MyController (default) or custom key via opts.binding
service(MyService, opts?)services.MyService (default) or custom key via opts.binding
repository(MyRepository, opts?)repositories.MyRepository (default) or custom key via opts.binding
dataSource(MyDataSource, opts?)datasources.MyDataSource (default) or custom key via opts.binding

initialize() Method Flow

Startup sequence executed by the initialize() method:

HookWhen to UseNotes
preConfigure()Register all resources (datasources, services, controllers)Nothing instantiated yet - order doesn't matter
register...()Framework iterates bindings and instantiates classesDataSources initialized first (other layers depend on them)
postConfigure()Logic after all resources configuredExample: fetch initial data from repository