Skip to content

Interface: ApplicationService ​

Application service is a singleton resolved from the container

Extends ​

  • Application<ContainerBindings extends Record<any, any> ? ContainerBindings : never>

Properties ​

PropertyTypeDescriptionInherited from
containerContainer<ContainerBindings>Reference to the AdonisJS IoC container. The value is defined after the "init" method callApplication.container
experimentalFlagsFeatureFlags<ExperimentalFlagsList>Check the status of the configured feature flags and act on themApplication.experimentalFlags
infoMap<string, any>Store info metadata about the app.Application.info
stubs{ create: () => Promise<StubsManager>; }Reference to the stubs module to scaffold resources or eject stubsApplication.stubs
stubs.create() => Promise<StubsManager>--
usingEdgeJSbooleanA flag to know if Edge provider is configured. When set to true, you may import edge.js packageApplication.usingEdgeJS
usingVineJSbooleanA flag to know if VineJS provider is configured. When set to true, you may import @vinejs/vine packageApplication.usingVineJS

Accessors ​

adonisVersion ​

Get Signature ​

ts
get adonisVersion(): SemverNode | null;

The parsed version for the "@adonisjs/core" package.

Returns ​

SemverNode | null

Inherited from ​

ts
Application.adonisVersion;

appName ​

Get Signature ​

ts
get appName(): any;

Returns the application name from the info map

Returns ​

any

Inherited from ​

ts
Application.appName;

appRoot ​

Get Signature ​

ts
get appRoot(): URL;

The URL for the root of the application

Returns ​

URL

Inherited from ​

ts
Application.appRoot;

config ​

Get Signature ​

ts
get config(): Config;

Reference to the config class. The value is defined after the "init" method call

Returns ​

Config

Inherited from ​

ts
Application.config;

generators ​

Get Signature ​

ts
get generators(): {
  singularControllerNames: string[];
  commandFileName: string;
  commandName: string;
  commandTerminalName: string;
  controllerFileName: string;
  controllerName: string;
  createEntity: {
     name: string;
     path: string;
  };
  eventFileName: string;
  eventName: string;
  exceptionFileName: string;
  exceptionName: string;
  factoryFileName: string;
  factoryName: string;
  importPath: string;
  listenerFileName: string;
  listenerName: string;
  mailerFileName: string;
  mailerName: string;
  mailFileName: string;
  mailName: string;
  middlewareFileName: string;
  middlewareName: string;
  modelFileName: string;
  modelName: string;
  policyFileName: string;
  policyName: string;
  providerFileName: string;
  providerName: string;
  seederFileName: string;
  seederName: string;
  serviceFileName: string;
  serviceName: string;
  tableName: string;
  testFileName: string;
  testGroupName: string;
  validatorActionName: string;
  validatorFileName: string;
  validatorName: string;
  viewFileName: string;
};

Reference to scaffolding generators

Returns ​
ts
{
  singularControllerNames: string[];
  commandFileName: string;
  commandName: string;
  commandTerminalName: string;
  controllerFileName: string;
  controllerName: string;
  createEntity: {
     name: string;
     path: string;
  };
  eventFileName: string;
  eventName: string;
  exceptionFileName: string;
  exceptionName: string;
  factoryFileName: string;
  factoryName: string;
  importPath: string;
  listenerFileName: string;
  listenerName: string;
  mailerFileName: string;
  mailerName: string;
  mailFileName: string;
  mailName: string;
  middlewareFileName: string;
  middlewareName: string;
  modelFileName: string;
  modelName: string;
  policyFileName: string;
  policyName: string;
  providerFileName: string;
  providerName: string;
  seederFileName: string;
  seederName: string;
  serviceFileName: string;
  serviceName: string;
  tableName: string;
  testFileName: string;
  testGroupName: string;
  validatorActionName: string;
  validatorFileName: string;
  validatorName: string;
  viewFileName: string;
}
NameType
singularControllerNamesstring[]
commandFileName()(entityName: string) => string
commandName()(entityName: string) => string
commandTerminalName()(entityName: string) => string
controllerFileName()(entityName: string, singular?: boolean) => string
controllerName()(entityName: string, singular?: boolean) => string
createEntity()(entityName: string) => { name: string; path: string; }
eventFileName()(entityName: string) => string
eventName()(entityName: string) => string
exceptionFileName()(entityName: string) => string
exceptionName()(entityName: string) => string
factoryFileName()(entityName: string) => string
factoryName()(entityName: string) => string
importPath()(...paths: string[]) => string
listenerFileName()(entityName: string) => string
listenerName()(entityName: string) => string
mailerFileName()(entityName: string, type?: "notification" | "provision") => string
mailerName()(entityName: string, type?: "notification" | "provision") => string
mailFileName()(entityName: string, type?: string) => string
mailName()(entityName: string, type?: string) => string
middlewareFileName()(entityName: string) => string
middlewareName()(entityName: string) => string
modelFileName()(entityName: string) => string
modelName()(entityName: string) => string
policyFileName()(entityName: string) => string
policyName()(entityName: string) => string
providerFileName()(entityName: string) => string
providerName()(entityName: string) => string
seederFileName()(entityName: string) => string
seederName()(entityName: string) => string
serviceFileName()(entityName: string) => string
serviceName()(entityName: string) => string
tableName()(entityName: string) => string
testFileName()(entityName: string) => string
testGroupName()(entity: { name: string; path: string; }) => string
validatorActionName()(entityName: string, action: string) => string
validatorFileName()(entityName: string) => string
validatorName()(entityName: string) => string
viewFileName()(entityName: string) => string

Inherited from ​

ts
Application.generators;

inDev ​

Get Signature ​

ts
get inDev(): boolean;

Return true when this.nodeEnvironment === 'development'

Returns ​

boolean

Inherited from ​

ts
Application.inDev;

inProduction ​

Get Signature ​

ts
get inProduction(): boolean;

Return true when this.nodeEnvironment === 'production'

Returns ​

boolean

Inherited from ​

ts
Application.inProduction;

inTest ​

Get Signature ​

ts
get inTest(): boolean;

Returns true when this.nodeEnvironment === 'test'

Returns ​

boolean

Inherited from ​

ts
Application.inTest;

isBooted ​

Get Signature ​

ts
get isBooted(): boolean;

A boolean to know if the application has been booted

Returns ​

boolean

Inherited from ​

ts
Application.isBooted;

isReady ​

Get Signature ​

ts
get isReady(): boolean;

A boolean to know if the application is ready

Returns ​

boolean

Inherited from ​

ts
Application.isReady;

isTerminated ​

Get Signature ​

ts
get isTerminated(): boolean;

A boolean to know if the application has been terminated

Returns ​

boolean

Inherited from ​

ts
Application.isTerminated;

isTerminating ​

Get Signature ​

ts
get isTerminating(): boolean;

A boolean to know if the application is in the middle of getting terminating

Returns ​

boolean

Inherited from ​

ts
Application.isTerminating;

managedByPm2 ​

Get Signature ​

ts
get managedByPm2(): boolean;

Find if the process is managed and run under pm2

Returns ​

boolean

Inherited from ​

ts
Application.managedByPm2;

nodeEnvironment ​

Get Signature ​

ts
get nodeEnvironment(): string;

Normalized current NODE_ENV

Returns ​

string

Inherited from ​

ts
Application.nodeEnvironment;

rcFile ​

Get Signature ​

ts
get rcFile(): RcFile;

Reference to the parsed rc file. The value is defined after the "init" method call

Returns ​

RcFile

Inherited from ​

ts
Application.rcFile;

version ​

Get Signature ​

ts
get version(): SemverNode | null;

Returns the application version from the info map

Returns ​

SemverNode | null

Inherited from ​

ts
Application.version;

Methods ​

boot() ​

ts
boot(): Promise<void>;

Boot the application. Calling this method performs the following operations.

  • Resolve providers and call the "register" method on them.
  • Call the "boot" method on providers
  • Run the "booted" hooks

Returns ​

Promise<void>

Inherited from ​

ts
Application.boot;

booted() ​

ts
booted(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): Promise<void>;

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.

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

Promise<void>

Inherited from ​

ts
Application.booted;

booting() ​

ts
booting(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;

Register hooks that are called before the app boot process starts

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

this

Inherited from ​

ts
Application.booting;

commandsPath() ​

ts
commandsPath(...paths: string[]): string;

Makes path to the commands directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.commandsPath;

configPath() ​

ts
configPath(...paths: string[]): string;

Makes path to the config directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.configPath;

contractsPath() ​

ts
contractsPath(...paths: string[]): string;

Makes path to the contracts directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Deprecated ​

Inherited from ​

ts
Application.contractsPath;

eventsPath() ​

ts
eventsPath(...paths: string[]): string;

Makes path to the events directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.eventsPath;

exceptionsPath() ​

ts
exceptionsPath(...paths: string[]): string;

Makes path to the exceptions directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.exceptionsPath;

factoriesPath() ​

ts
factoriesPath(...paths: string[]): string;

Makes path to the factories directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.factoriesPath;

getEnvironment() ​

ts
getEnvironment(): AppEnvironments;

The current environment in which the application is running

Returns ​

AppEnvironments

Inherited from ​

ts
Application.getEnvironment;

getState() ​

ts
getState(): ApplicationStates;

The current state of the application.

Returns ​

ApplicationStates

Inherited from ​

ts
Application.getState;

httpControllersPath() ​

ts
httpControllersPath(...paths: string[]): string;

Makes path to the http controllers directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.httpControllersPath;

import() ​

ts
import(moduleIdentifier: string): any;

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.

Parameters ​

ParameterType
moduleIdentifierstring

Returns ​

any

Inherited from ​

ts
Application.import;

importDefault() ​

ts
importDefault<T>(moduleIdentifier: string): Promise<T extends {
  default: A;
} ? A : never>;

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.

Type Parameters ​

Type Parameter
T extends object

Parameters ​

ParameterType
moduleIdentifierstring

Returns ​

Promise<T extends { default: A; } ? A : never>

Inherited from ​

ts
Application.importDefault;

init() ​

ts
init(): Promise<void>;

Initiate the application. Calling this method performs following operations.

  • Parses the "adonisrc.js" file
  • Validate and set environment variables
  • Loads the application config from the configured config dir.
  • Configures the logger
  • Instantiates the IoC container

Returns ​

Promise<void>

Inherited from ​

ts
Application.init;

initiating() ​

ts
initiating(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;

Register hooks that are called before the app starts the initiating process

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

this

Inherited from ​

ts
Application.initiating;

languageFilesPath() ​

ts
languageFilesPath(...paths: string[]): string;

Makes path to the language files directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.languageFilesPath;

listen() ​

ts
listen(signal: Signals, callback: SignalsListener): this;

Listen for a process signal. This method is same as calling "process.on(signal)"

Parameters ​

ParameterType
signalSignals
callbackSignalsListener

Returns ​

this

Inherited from ​

ts
Application.listen;

listenersPath() ​

ts
listenersPath(...paths: string[]): string;

Makes path to the listeners directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.listenersPath;

listenIf() ​

ts
listenIf(
   conditional: boolean,
   signal: Signals,
   callback: SignalsListener): this;

Listen for a process signal conditionally.

Parameters ​

ParameterType
conditionalboolean
signalSignals
callbackSignalsListener

Returns ​

this

Inherited from ​

ts
Application.listenIf;

listenOnce() ​

ts
listenOnce(signal: Signals, callback: SignalsListener): this;

Listen for a process signal once. This method is same as calling "process.once(signal)"

Parameters ​

ParameterType
signalSignals
callbackSignalsListener

Returns ​

this

Inherited from ​

ts
Application.listenOnce;

listenOnceIf() ​

ts
listenOnceIf(
   conditional: boolean,
   signal: Signals,
   callback: SignalsListener): this;

Listen for a process signal once conditionally.

Parameters ​

ParameterType
conditionalboolean
signalSignals
callbackSignalsListener

Returns ​

this

Inherited from ​

ts
Application.listenOnceIf;

mailersPath() ​

ts
mailersPath(...paths: string[]): string;

Makes path to the mailers directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.mailersPath;

mailsPath() ​

ts
mailsPath(...paths: string[]): string;

Makes path to the mails directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.mailsPath;

makePath() ​

ts
makePath(...paths: string[]): string;

Returns file system path from the application root.

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.makePath;

makeURL() ​

ts
makeURL(...paths: string[]): URL;

Returns URL to a path from the application root.

Parameters ​

ParameterType
...pathsstring[]

Returns ​

URL

Inherited from ​

ts
Application.makeURL;

middlewarePath() ​

ts
middlewarePath(...paths: string[]): string;

Makes path to the middleware directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.middlewarePath;

migrationsPath() ​

ts
migrationsPath(...paths: string[]): string;

Makes path to the migrations directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.migrationsPath;

modelsPath() ​

ts
modelsPath(...paths: string[]): string;

Makes path to the models directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.modelsPath;

notify() ​

ts
notify(
   message: any,
   sendHandle?: any,
   options?: {
  keepOpen?: boolean;
  swallowErrors?: boolean;
},
   callback?: (error: Error | null) => void): void;

Notify the parent process when the Node.js process is spawned with an IPC channel. The arguments accepted are same as "process.send"

Parameters ​

ParameterType
messageany
sendHandle?any
options?{ keepOpen?: boolean; swallowErrors?: boolean; }
options.keepOpen?boolean
options.swallowErrors?boolean
callback?(error: Error | null) => void

Returns ​

void

Inherited from ​

ts
Application.notify;

policiesPath() ​

ts
policiesPath(...paths: string[]): string;

Makes path to the policies directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.policiesPath;

providersPath() ​

ts
providersPath(...paths: string[]): string;

Makes path to the providers directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.providersPath;

publicPath() ​

ts
publicPath(...paths: string[]): string;

Makes path to the public directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.publicPath;

rcContents() ​

ts
rcContents(value: Record<string, any>): this;

Specify the contents of the "adonisrc.js" file as an object. Calling this method will disable loading the "adonisrc.js" file from the disk.

Parameters ​

ParameterType
valueRecord<string, any>

Returns ​

this

Inherited from ​

ts
Application.rcContents;

ready() ​

ts
ready(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): Promise<void>;

Register hooks that are called when the app is ready

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

Promise<void>

Inherited from ​

ts
Application.ready;

relativePath() ​

ts
relativePath(absolutePath: string): string;

Returns relative path to a file from the app root

Parameters ​

ParameterType
absolutePathstring

Returns ​

string

Inherited from ​

ts
Application.relativePath;

seedersPath() ​

ts
seedersPath(...paths: string[]): string;

Makes path to the seeders directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.seedersPath;

servicesPath() ​

ts
servicesPath(...paths: string[]): string;

Makes path to the services directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.servicesPath;

setEnvironment() ​

ts
setEnvironment(environment: AppEnvironments): this;

Switch the environment in which the app is running. The environment can only be changed before the app is booted.

Parameters ​

ParameterType
environmentAppEnvironments

Returns ​

this

Inherited from ​

ts
Application.setEnvironment;

start() ​

ts
start(callback: (app: this) => void | Promise<void>): Promise<void>;

Start the application. Calling this method performs the following operations.

  • Run the "start" lifecycle hooks on all the providers
  • Start the application by invoking the supplied callback
  • Run the "ready" lifecycle hooks on all the providers
  • Run the "ready" application hooks

Parameters ​

ParameterType
callback(app: this) => void | Promise<void>

Returns ​

Promise<void>

Inherited from ​

ts
Application.start;

starting() ​

ts
starting(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;

Register hooks that are called when the app is starting

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

this

Inherited from ​

ts
Application.starting;

startPath() ​

ts
startPath(...paths: string[]): string;

Makes path to the start directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.startPath;

terminate() ​

ts
terminate(): Promise<void>;

Terminate application gracefully. Calling this method performs the following operations.

  • Run "shutdown" hooks on all the providers
  • Run "terminating" app lifecycle hooks

Returns ​

Promise<void>

Inherited from ​

ts
Application.terminate;

terminating() ​

ts
terminating(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;

Register hooks that are called before the app is terminated.

Parameters ​

ParameterType
handlerHookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>

Returns ​

this

Inherited from ​

ts
Application.terminating;

tmpPath() ​

ts
tmpPath(...paths: string[]): string;

Makes path to the tmp directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.tmpPath;

toJSON() ​

ts
toJSON(): {
  adonisVersion: string | null;
  appName: any;
  environment: AppEnvironments;
  isReady: boolean;
  isTerminating: boolean;
  nodeEnvironment: string;
  version: string | null;
};

JSON representation of the application

Returns ​

ts
{
  adonisVersion: string | null;
  appName: any;
  environment: AppEnvironments;
  isReady: boolean;
  isTerminating: boolean;
  nodeEnvironment: string;
  version: string | null;
}
NameType
adonisVersionstring | null
appNameany
environmentAppEnvironments
isReadyboolean
isTerminatingboolean
nodeEnvironmentstring
versionstring | null

Inherited from ​

ts
Application.toJSON;

useConfig() ​

ts
useConfig(values: Record<any, any>): this;

Define the config values to use when booting the config provider. Calling this method disables reading files from the config directory.

Parameters ​

ParameterType
valuesRecord<any, any>

Returns ​

this

Inherited from ​

ts
Application.useConfig;

validatorsPath() ​

ts
validatorsPath(...paths: string[]): string;

Makes path to the validators directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.validatorsPath;

viewsPath() ​

ts
viewsPath(...paths: string[]): string;

Makes path to the views directory

Parameters ​

ParameterType
...pathsstring[]

Returns ​

string

Inherited from ​

ts
Application.viewsPath;