Type definition for IoC container bindings
Creates an instance of Application.
The root URL of the application
Configuration options
The application environment
Optionalimporter?: ImporterOptional module importer function
Stores metadata information about the application including app name, version, and AdonisJS version.
Reference to the stubs module for scaffolding resources or ejecting stubs. Provides functionality to create and manage code generation templates.
Feature flags manager for checking the status of experimental features. Reads configuration from adonisrc.js experimental section.
Flag indicating if VineJS provider is configured and available. When true, the @vinejs/vine package can be safely imported.
Flag indicating if Edge template engine provider is configured. When true, the edge.js package can be safely imported.
Reference to the AdonisJS IoC container. The container manages dependency injection and service binding throughout the application. Available after the "init" method has been called.
Returns the application name from the info map. Defaults to 'adonisjs_app' if not set.
Returns the application version from the info map. Returns null if no version is set.
The parsed version for the "@adonisjs/core" package. Returns null if no version is available.
The URL for the root of the application directory.
A boolean to know if the application has been booted. Returns true when the application state is beyond 'initiated'.
A boolean to know if the application is ready and fully started. Returns true only when the application state is 'ready'.
A boolean to know if the application has been terminated. Returns true only when the application state is 'terminated'.
A boolean to know if the application is in the middle of the termination process but not yet fully terminated.
Reference to the config instance. The value is available after the "init" method has been called.
Reference to the parsed adonisrc.js file. The value is available after the "init" method has been called.
Normalized current NODE_ENV value. Converts common variations to standard values (development, production, test).
Returns true when the NODE_ENV is set to 'production'. Useful for conditional logic based on production environment.
Returns true when the NODE_ENV is set to 'development'. Useful for enabling development-specific features.
Returns true when the NODE_ENV is set to 'test'. Useful for enabling test-specific behavior.
Returns true if the process is managed and running under PM2. Detected by checking for the pm2_id environment variable.
Reference to scaffolding generators for creating application files. Provides utilities for generating controllers, models, migrations, etc.
List of controller names that should always be generated in singular form. These are typically system/admin controllers or special-purpose controllers that don't represent plural resources.
Creates the entity path and name from user input. Parses the entity name to separate directory path from the actual name, handling file extensions and nested paths.
The entity name which may include path and extension
Object containing the parsed path and name
Converts an entity name to a database table name. Removes 'table' suffix, converts to model name format, then pluralizes and converts to snake_case.
The entity name to convert
Database table name in snake_case plural form
Converts an entity name to a model class name. Removes file extension and 'model' suffix, singularizes, and converts to PascalCase.
The entity name to convert
Model class name in PascalCase singular form
Converts an entity name to a model file name. Uses the model name and converts to snake_case with .ts extension.
The entity name to convert
Model file name in snake_case with .ts extension
Converts an entity name to a controller class name. Removes file extension and 'controller' suffix, then applies singularization rules based on special names list or parameter.
The entity name to convert
Force singular form regardless of special names
Controller class name in PascalCase with 'Controller' suffix
Converts an entity name to a controller file name. Uses the controller name and converts to snake_case with .ts extension.
The entity name to convert
Force singular form for the controller name
Controller file name in snake_case with .ts extension
Converts an entity name to an event class name. Removes file extension and 'event' suffix, then converts to PascalCase.
The entity name to convert
Event class name in PascalCase
Converts an entity name to a listener class name. Removes file extension and 'listener' suffix, then converts to PascalCase.
The entity name to convert
Listener class name in PascalCase
Converts an entity name to a middleware class name. Removes file extension and 'middleware' suffix, then converts to PascalCase with 'Middleware' suffix.
The entity name to convert
Middleware class name in PascalCase with 'Middleware' suffix
Converts an entity name to a middleware file name. Uses the middleware name and converts to snake_case with .ts extension.
The entity name to convert
Middleware file name in snake_case with .ts extension
Converts an entity name to a provider class name. Removes file extension and 'provider' suffix, singularizes, then converts to PascalCase with 'Provider' suffix.
The entity name to convert
Provider class name in PascalCase with 'Provider' suffix
Converts an entity name to a provider file name. Uses the provider name and converts to snake_case with .ts extension.
The entity name to convert
Provider file name in snake_case with .ts extension
Converts an entity name to a policy class name. Removes file extension, 'policy' and 'model' suffixes, singularizes, then converts to PascalCase with 'Policy' suffix.
The entity name to convert
Policy class name in PascalCase with 'Policy' suffix
Converts an entity name to a factory class name. Removes file extension, 'factory' and 'model' suffixes, singularizes, then converts to PascalCase with 'Factory' suffix.
The entity name to convert
Factory class name in PascalCase with 'Factory' suffix
Converts an entity name to a service class name. Removes file extension, 'service' and 'model' suffixes, singularizes, then converts to PascalCase with 'Service' suffix.
The entity name to convert
Service class name in PascalCase with 'Service' suffix
Converts an entity name to a seeder class name. Removes file extension, 'seeder' and 'model' suffixes, singularizes, then converts to PascalCase with 'Seeder' suffix.
The entity name to convert
Seeder class name in PascalCase with 'Seeder' suffix
Converts an entity name to a command terminal name. Creates a namespaced command name using dash-case format, where the first part becomes the namespace and remaining parts are joined with colons.
The entity name to convert
Command terminal name in namespace:command format
Converts an entity name to a command class name. Removes file extension and 'command' suffix, then converts to PascalCase.
The entity name to convert
Command class name in PascalCase
Converts an entity name to a validator class name. Removes file extension and 'validator' suffix, singularizes, then converts to PascalCase.
The entity name to convert
Validator class name in PascalCase
Converts an entity name and action to a validator action name. Creates a camelCase name by prefixing with action and suffixing with 'validator'.
The entity name to convert
The action name (e.g., 'create', 'update')
Validator action name in camelCase
Converts an entity name to an exception class name. Removes file extension and 'exception' suffix, then converts to PascalCase with 'Exception' suffix.
The entity name to convert
Exception class name in PascalCase with 'Exception' suffix
Converts an entity name to an exception file name. Uses the exception name and converts to snake_case with .ts extension.
The entity name to convert
Exception file name in snake_case with .ts extension
Converts an entity name to a mailer class name. Removes file extension and various suffixes, then converts to PascalCase with the specified type suffix.
The entity name to convert
The mailer type ('notification' or 'provision')
Mailer class name in PascalCase with type suffix
Converts an entity name to a mailer file name. Uses the mailer name and converts to snake_case with .ts extension.
The entity name to convert
The mailer type ('notification' or 'provision')
Mailer file name in snake_case with .ts extension
Converts an entity name to a class-based mail name. Removes file extension and various suffixes, then converts to PascalCase with the specified type suffix. Similar to mailerName but with more flexible type.
The entity name to convert
The mail type (default: 'notification')
Mail class name in PascalCase with type suffix
Converts an entity name to a class-based mail file name. Uses the mail name and converts to snake_case with .ts extension.
The entity name to convert
The mail type (default: 'notification')
Mail file name in snake_case with .ts extension
Converts an entity to a test group name. Creates a human-readable test group name by combining path and name, removing extensions and converting to sentence case.
Object containing path and name properties
Test group name in sentence case
Converts an entity name to a test file name. Removes file extension and '.spec' suffix, converts to snake_case, then adds '.spec.ts' extension.
The entity name to convert
Test file name in snake_case with .spec.ts extension
Converts an entity name to a view template file name. Removes file extension, converts to snake_case, and adds '.edge' extension for Edge template files.
The entity name to convert
View file name in snake_case with .edge extension
The current environment in which the application is running
The current application environment
Switch the environment in which the app is running. The environment can only be changed before the app is booted.
The new environment to set
Returns the application instance for method chaining
Specify the contents of the "adonisrc.js" file as an object. Calling this method will disable loading the "adonisrc.js" file from the disk.
The RC file contents as an object
Returns the application instance for method chaining
Define the config values to use when booting the config provider. Calling this method disables reading files from the config directory.
The config values to use
Returns the application instance for method chaining
Notify the parent process when the Node.js process is spawned with an IPC channel. The arguments accepted are same as "process.send"
The message to send to the parent process
OptionalsendHandle: anyOptional handle to send with the message
Optionaloptions: { swallowErrors?: boolean; keepOpen?: boolean }Options for sending the message
OptionalswallowErrors?: booleanWhether to swallow errors
OptionalkeepOpen?: booleanWhether to keep the connection open
Optionalcallback: (error: null | Error) => voidCallback function to handle send result
Listen for a process signal. This method is same as calling "process.on(signal)"
The signal to listen for
The callback to execute when signal is received
Returns the application instance for method chaining
Listen for a process signal once. This method is same as calling "process.once(signal)"
The signal to listen for
The callback to execute when signal is received
Returns the application instance for method chaining
Listen for a process signal conditionally.
Whether to register the listener
The signal to listen for
The callback to execute when signal is received
Returns the application instance for method chaining
Listen for a process signal once conditionally.
Whether to register the listener
The signal to listen for
The callback to execute when signal is received
Returns the application instance for method chaining
Register hooks that are called before the app starts the initiating process
The hook handler function to register
Returns the application instance for method chaining
Initiate the application. Calling this method performs following operations:
Promise that resolves when initiation is complete
Register hooks that are called before the app boot process starts
The hook handler function to register
Returns the application instance for method chaining
Boot the application. Calling this method performs the following operations:
Promise that resolves when boot is complete
Register a hook to get notified when the application has been booted.
The hook will be called immediately if the app has already been booted.
The hook handler function to register
Promise that resolves after the handler is executed
Register hooks that are called when the app is starting
The hook handler function to register
Returns the application instance for method chaining
Start the application. Calling this method performs the following operations:
The callback function to invoke when starting the app
Promise that resolves when start is complete
Register hooks that are called when the app is ready.
The hook will be called immediately if the app is already ready.
The hook handler function to register
Promise that resolves after the handler is executed
Register hooks that are called before the app is terminated.
The hook handler function to register
Returns the application instance for method chaining
Terminate application gracefully. Calling this method performs the following operations:
Promise that resolves when termination is complete
Returns relative path to a file from the app root
The absolute path to convert
The relative path from app root
Returns URL to a path from the application root.
Path segments to join
The constructed URL
Returns file system path from the application root.
Path segments to join
The constructed file system path
Makes path to the config directory
Path segments to append to config directory
The constructed config directory path
Makes path to the public directory
Path segments to append to public directory
The constructed public directory path
Makes path to the providers directory
Path segments to append to providers directory
The constructed providers directory path
Makes path to the factories directory
Path segments to append to factories directory
The constructed factories directory path
Makes path to the migrations directory
Path segments to append to migrations directory
The constructed migrations directory path
Makes path to the seeders directory
Path segments to append to seeders directory
The constructed seeders directory path
Makes path to the language files directory
Path segments to append to language files directory
The constructed language files directory path
Makes path to the views directory
Path segments to append to views directory
The constructed views directory path
Makes path to the start directory
Path segments to append to start directory
The constructed start directory path
Makes path to the tmp directory
Path segments to append to tmp directory
The constructed tmp directory path
Makes path to the http controllers directory
Path segments to append to http controllers directory
The constructed http controllers directory path
Makes path to the models directory
Path segments to append to models directory
The constructed models directory path
Makes path to the services directory
Path segments to append to services directory
The constructed services directory path
Makes path to the exceptions directory
Path segments to append to exceptions directory
The constructed exceptions directory path
Makes path to the mailers directory
Path segments to append to mailers directory
The constructed mailers directory path
Makes path to the mails directory
Path segments to append to mails directory
The constructed mails directory path
Makes path to the middleware directory
Path segments to append to middleware directory
The constructed middleware directory path
Makes path to the policies directory
Path segments to append to policies directory
The constructed policies directory path
Makes path to the validators directory
Path segments to append to validators directory
The constructed validators directory path
Makes path to the commands directory
Path segments to append to commands directory
The constructed commands directory path
Makes path to the events directory
Path segments to append to events directory
The constructed events directory path
Makes path to the listeners directory
Path segments to append to listeners directory
The constructed listeners directory path
Makes path to the client directory for writing generated output
Path segments to append to events directory
The constructed directory path
Makes path to the server directory for writing generated output
Path segments to append to events directory
The constructed directory path
Import a module by identifier. This method uses the importer function defined at the time of creating the application instance and throws an error if no importer was defined.
The module identifier to import
The imported module
Import a module by identifier and return its default export. This method uses the importer function defined at the time of creating the application instance and throws an error if no importer was defined.
The type of the default export
The module identifier to import
The default export of the imported module
JSON representation of the application
The application state as a JSON object
Application class manages the state of an AdonisJS application. It includes:
The Application class extends Macroable to allow runtime extension of functionality. It manages the entire lifecycle from creation to termination, providing hooks at each stage for customization.