or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ace-commands.mdapplication.mdauth-hash.mdcommands.mdconfig-env.mdevents.mdhelpers.mdhttp-server.mdindex.mdlogging.mdtest-utils.md
tile.json

application.mddocs/

Application Bootstrapping

Core application lifecycle management and dependency injection container system for AdonisJS applications. The Ignitor class serves as the central bootstrapper that manages the entire application lifecycle.

Capabilities

Ignitor Class

The central application bootstrapper that manages application lifecycle across different environments (web, CLI, test).

/**
 * Ignitor is used to instantiate an AdonisJS application in different
 * known environments.
 */
class Ignitor {
  /**
   * Create new Ignitor instance
   * @param appRoot - Application root URL
   * @param options - Optional configuration options
   */
  constructor(appRoot: URL, options?: IgnitorOptions);

  /**
   * Create an instance of AdonisJS application
   * @param environment - The environment to run the application in
   * @returns Application service instance
   */
  createApp(environment: AppEnvironments): ApplicationService;

  /**
   * Get access to the application instance created by processes
   * @returns Current application instance or undefined
   */
  getApp(): ApplicationService | undefined;

  /**
   * Get instance of the HTTPServerProcess
   * @returns HTTP server process instance
   */
  httpServer(): HttpServerProcess;

  /**
   * Get an instance of the AceProcess class
   * @returns Ace CLI process instance
   */
  ace(): AceProcess;

  /**
   * Get an instance of the TestRunnerProcess class
   * @returns Test runner process instance
   */
  testRunner(): TestRunnerProcess;

  /**
   * Tap to access the application class instance during creation
   * @param callback - Function to call with application instance
   * @returns This ignitor instance for chaining
   */
  tap(callback: (app: ApplicationService) => void): this;

  /**
   * Terminates the app by calling the "app.terminate" method
   */
  terminate(): Promise<void>;
}

Usage Examples:

import { Ignitor } from "@adonisjs/core";

// Basic application setup
const ignitor = new Ignitor(new URL("./", import.meta.url));

// With custom importer
const ignitor = new Ignitor(new URL("./", import.meta.url), {
  importer: (filePath) => import(filePath)
});

// Access application during creation
ignitor.tap((app) => {
  console.log("Application created:", app.version);
});

// Create application instance
const app = ignitor.createApp("web");

// Start different processes
const httpServer = ignitor.httpServer();
const ace = ignitor.ace();
const testRunner = ignitor.testRunner();

Application Service

The core application instance providing container management and service access.

/**
 * Application service interface providing access to core services
 */
interface ApplicationService {
  /** Dependency injection container */
  container: Container;
  /** Configuration manager */
  config: ConfigManager;
  /** Environment manager */
  env: Env;
  /** Logger manager */
  logger: LoggerManager;
  /** Event emitter */
  emitter: Emitter;
  /** Hash manager */
  hash: HashManager;
  /** Encryption service */
  encryption: Encryption;
  /** Application version */
  version: string;
  /** Application environment */
  environment: AppEnvironments;
  /** Gracefully terminate the application */
  terminate(): Promise<void>;
}

Process Classes

Different process types for various application modes.

/**
 * HTTP server process for web applications
 */
class HttpServerProcess {
  constructor(ignitor: Ignitor);
  
  /**
   * Start the HTTP server
   * @param callback - Optional callback when server is ready
   */
  start(callback?: () => void): Promise<void>;
  
  /**
   * Close the HTTP server
   */
  close(): Promise<void>;
}

/**
 * Ace CLI process for command-line operations
 */
class AceProcess {
  constructor(ignitor: Ignitor);
  
  /**
   * Handle CLI arguments and execute commands
   * @param argv - Command line arguments
   */
  handle(argv: string[]): Promise<void>;
}

/**
 * Test runner process for running tests
 */
class TestRunnerProcess {
  constructor(ignitor: Ignitor);
  
  /**
   * Start the test runner
   * @param callback - Optional callback when tests are ready
   */
  start(callback?: () => void): Promise<void>;
}

Configuration Provider

Type-safe configuration providers that resolve after application boot.

/**
 * Configuration provider function for creating lazy-loaded configs
 * @param resolver - Function that receives app instance and returns config
 * @returns Configuration provider object
 */
function configProvider<T>(
  resolver: (app: ApplicationService) => Promise<T>
): ConfigProvider<T>;

/**
 * Configuration provider type
 */
type ConfigProvider<T> = {
  type: 'provider';
  resolver: (app: ApplicationService) => Promise<T>;
};

Usage Examples:

import { configProvider } from "@adonisjs/core";

// Database configuration provider
const databaseConfig = configProvider(async (app) => {
  const { default: env } = await import("@adonisjs/env");
  
  return {
    connection: env.get("DB_CONNECTION", "sqlite"),
    connections: {
      sqlite: {
        client: "sqlite3",
        connection: {
          filename: app.makePath("database/app.db")
        }
      }
    }
  };
});

Dependency Injection

Container access and injection decorators.

/**
 * Dependency injection decorator
 * @param tokens - Container binding tokens to inject
 */
function inject(...tokens: (string | symbol)[]): ClassDecorator;

/**
 * Container interface from @adonisjs/fold
 */
interface Container {
  bind<T>(token: string | symbol, value: T): void;
  singleton<T>(token: string | symbol, value: T): void;
  make<T>(token: string | symbol): T;
  resolve<T>(target: Constructor<T>): T;
}

Types

interface IgnitorOptions {
  /** Custom module importer function */
  importer?: Importer;
}

type Importer = (filePath: string) => Promise<any>;

type AppEnvironments = "web" | "console" | "test" | "repl";

interface ContainerBindings {
  [key: string]: any;
}

type Constructor<T = {}> = new (...args: any[]) => T;