Interface: ApplicationService
Application service is a singleton resolved from the container
Extends
Application<ContainerBindingsextendsRecord<any,any> ?ContainerBindings:never>
Properties
Accessors
adonisVersion
Get Signature
get adonisVersion(): SemverNode | null;The parsed version for the "@adonisjs/core" package.
Returns
SemverNode | null
Inherited from
Application.adonisVersion;appName
Get Signature
get appName(): any;Returns the application name from the info map
Returns
any
Inherited from
Application.appName;appRoot
Get Signature
get appRoot(): URL;The URL for the root of the application
Returns
URL
Inherited from
Application.appRoot;config
Get Signature
get config(): Config;Reference to the config class. The value is defined after the "init" method call
Returns
Config
Inherited from
Application.config;generators
Get Signature
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
{
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;
}| Name | Type |
|---|---|
singularControllerNames | string[] |
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
Application.generators;inDev
Get Signature
get inDev(): boolean;Return true when this.nodeEnvironment === 'development'
Returns
boolean
Inherited from
Application.inDev;inProduction
Get Signature
get inProduction(): boolean;Return true when this.nodeEnvironment === 'production'
Returns
boolean
Inherited from
Application.inProduction;inTest
Get Signature
get inTest(): boolean;Returns true when this.nodeEnvironment === 'test'
Returns
boolean
Inherited from
Application.inTest;isBooted
Get Signature
get isBooted(): boolean;A boolean to know if the application has been booted
Returns
boolean
Inherited from
Application.isBooted;isReady
Get Signature
get isReady(): boolean;A boolean to know if the application is ready
Returns
boolean
Inherited from
Application.isReady;isTerminated
Get Signature
get isTerminated(): boolean;A boolean to know if the application has been terminated
Returns
boolean
Inherited from
Application.isTerminated;isTerminating
Get Signature
get isTerminating(): boolean;A boolean to know if the application is in the middle of getting terminating
Returns
boolean
Inherited from
Application.isTerminating;managedByPm2
Get Signature
get managedByPm2(): boolean;Find if the process is managed and run under pm2
Returns
boolean
Inherited from
Application.managedByPm2;nodeEnvironment
Get Signature
get nodeEnvironment(): string;Normalized current NODE_ENV
Returns
string
Inherited from
Application.nodeEnvironment;rcFile
Get Signature
get rcFile(): RcFile;Reference to the parsed rc file. The value is defined after the "init" method call
Returns
RcFile
Inherited from
Application.rcFile;version
Get Signature
get version(): SemverNode | null;Returns the application version from the info map
Returns
SemverNode | null
Inherited from
Application.version;Methods
boot()
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
Application.boot;booted()
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
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
Promise<void>
Inherited from
Application.booted;booting()
booting(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;Register hooks that are called before the app boot process starts
Parameters
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
this
Inherited from
Application.booting;commandsPath()
commandsPath(...paths: string[]): string;Makes path to the commands directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.commandsPath;configPath()
configPath(...paths: string[]): string;Makes path to the config directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.configPath;contractsPath()
contractsPath(...paths: string[]): string;Makes path to the contracts directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Deprecated
Inherited from
Application.contractsPath;eventsPath()
eventsPath(...paths: string[]): string;Makes path to the events directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.eventsPath;exceptionsPath()
exceptionsPath(...paths: string[]): string;Makes path to the exceptions directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.exceptionsPath;factoriesPath()
factoriesPath(...paths: string[]): string;Makes path to the factories directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.factoriesPath;getEnvironment()
getEnvironment(): AppEnvironments;The current environment in which the application is running
Returns
AppEnvironments
Inherited from
Application.getEnvironment;getState()
getState(): ApplicationStates;The current state of the application.
Returns
ApplicationStates
Inherited from
Application.getState;httpControllersPath()
httpControllersPath(...paths: string[]): string;Makes path to the http controllers directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.httpControllersPath;import()
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
| Parameter | Type |
|---|---|
moduleIdentifier | string |
Returns
any
Inherited from
Application.import;importDefault()
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
| Parameter | Type |
|---|---|
moduleIdentifier | string |
Returns
Promise<T extends { default: A; } ? A : never>
Inherited from
Application.importDefault;init()
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
Application.init;initiating()
initiating(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;Register hooks that are called before the app starts the initiating process
Parameters
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
this
Inherited from
Application.initiating;languageFilesPath()
languageFilesPath(...paths: string[]): string;Makes path to the language files directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.languageFilesPath;listen()
listen(signal: Signals, callback: SignalsListener): this;Listen for a process signal. This method is same as calling "process.on(signal)"
Parameters
| Parameter | Type |
|---|---|
signal | Signals |
callback | SignalsListener |
Returns
this
Inherited from
Application.listen;listenersPath()
listenersPath(...paths: string[]): string;Makes path to the listeners directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.listenersPath;listenIf()
listenIf(
conditional: boolean,
signal: Signals,
callback: SignalsListener): this;Listen for a process signal conditionally.
Parameters
| Parameter | Type |
|---|---|
conditional | boolean |
signal | Signals |
callback | SignalsListener |
Returns
this
Inherited from
Application.listenIf;listenOnce()
listenOnce(signal: Signals, callback: SignalsListener): this;Listen for a process signal once. This method is same as calling "process.once(signal)"
Parameters
| Parameter | Type |
|---|---|
signal | Signals |
callback | SignalsListener |
Returns
this
Inherited from
Application.listenOnce;listenOnceIf()
listenOnceIf(
conditional: boolean,
signal: Signals,
callback: SignalsListener): this;Listen for a process signal once conditionally.
Parameters
| Parameter | Type |
|---|---|
conditional | boolean |
signal | Signals |
callback | SignalsListener |
Returns
this
Inherited from
Application.listenOnceIf;mailersPath()
mailersPath(...paths: string[]): string;Makes path to the mailers directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.mailersPath;mailsPath()
mailsPath(...paths: string[]): string;Makes path to the mails directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.mailsPath;makePath()
makePath(...paths: string[]): string;Returns file system path from the application root.
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.makePath;makeURL()
makeURL(...paths: string[]): URL;Returns URL to a path from the application root.
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
URL
Inherited from
Application.makeURL;middlewarePath()
middlewarePath(...paths: string[]): string;Makes path to the middleware directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.middlewarePath;migrationsPath()
migrationsPath(...paths: string[]): string;Makes path to the migrations directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.migrationsPath;modelsPath()
modelsPath(...paths: string[]): string;Makes path to the models directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.modelsPath;notify()
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
| Parameter | Type |
|---|---|
message | any |
sendHandle? | any |
options? | { keepOpen?: boolean; swallowErrors?: boolean; } |
options.keepOpen? | boolean |
options.swallowErrors? | boolean |
callback? | (error: Error | null) => void |
Returns
void
Inherited from
Application.notify;policiesPath()
policiesPath(...paths: string[]): string;Makes path to the policies directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.policiesPath;providersPath()
providersPath(...paths: string[]): string;Makes path to the providers directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.providersPath;publicPath()
publicPath(...paths: string[]): string;Makes path to the public directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.publicPath;rcContents()
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
| Parameter | Type |
|---|---|
value | Record<string, any> |
Returns
this
Inherited from
Application.rcContents;ready()
ready(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): Promise<void>;Register hooks that are called when the app is ready
Parameters
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
Promise<void>
Inherited from
Application.ready;relativePath()
relativePath(absolutePath: string): string;Returns relative path to a file from the app root
Parameters
| Parameter | Type |
|---|---|
absolutePath | string |
Returns
string
Inherited from
Application.relativePath;seedersPath()
seedersPath(...paths: string[]): string;Makes path to the seeders directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.seedersPath;servicesPath()
servicesPath(...paths: string[]): string;Makes path to the services directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.servicesPath;setEnvironment()
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
| Parameter | Type |
|---|---|
environment | AppEnvironments |
Returns
this
Inherited from
Application.setEnvironment;start()
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
| Parameter | Type |
|---|---|
callback | (app: this) => void | Promise<void> |
Returns
Promise<void>
Inherited from
Application.start;starting()
starting(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;Register hooks that are called when the app is starting
Parameters
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
this
Inherited from
Application.starting;startPath()
startPath(...paths: string[]): string;Makes path to the start directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.startPath;terminate()
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
Application.terminate;terminating()
terminating(handler: HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]>): this;Register hooks that are called before the app is terminated.
Parameters
| Parameter | Type |
|---|---|
handler | HookHandler<[Application<ContainerBindings>], [Application<ContainerBindings>]> |
Returns
this
Inherited from
Application.terminating;tmpPath()
tmpPath(...paths: string[]): string;Makes path to the tmp directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.tmpPath;toJSON()
toJSON(): {
adonisVersion: string | null;
appName: any;
environment: AppEnvironments;
isReady: boolean;
isTerminating: boolean;
nodeEnvironment: string;
version: string | null;
};JSON representation of the application
Returns
{
adonisVersion: string | null;
appName: any;
environment: AppEnvironments;
isReady: boolean;
isTerminating: boolean;
nodeEnvironment: string;
version: string | null;
}| Name | Type |
|---|---|
adonisVersion | string | null |
appName | any |
environment | AppEnvironments |
isReady | boolean |
isTerminating | boolean |
nodeEnvironment | string |
version | string | null |
Inherited from
Application.toJSON;useConfig()
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
| Parameter | Type |
|---|---|
values | Record<any, any> |
Returns
this
Inherited from
Application.useConfig;validatorsPath()
validatorsPath(...paths: string[]): string;Makes path to the validators directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.validatorsPath;viewsPath()
viewsPath(...paths: string[]): string;Makes path to the views directory
Parameters
| Parameter | Type |
|---|---|
...paths | string[] |
Returns
string
Inherited from
Application.viewsPath;