@athenna/core
Version:
One foundation for multiple applications.
173 lines (172 loc) • 5.76 kB
TypeScript
/**
* @athenna/core
*
* (c) João Lenon <lenon@athenna.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type { CronOptions, HttpOptions, IgniteOptions, ConsoleOptions } from '#src/types';
import { Ioc } from '@athenna/ioc';
import type { ReplImpl } from '#src/repl/ReplImpl';
import { Macroable } from '@athenna/common';
export declare class Ignite extends Macroable {
/**
* The Athenna service provider instance (Ioc container).
*/
container: Ioc;
/**
* The parent url path where the Ignite was called.
*
* @example
* ```ts
* new Ignite(import.meta.url)...
* ```
*/
parentURL: string;
/**
* The Ignite options that will be used in "fire" method.
*/
options: IgniteOptions;
/**
* Load the Ignite class using the options and meta url path.
*/
load(parentURL: string, options?: IgniteOptions): Promise<this>;
/**
* Ignite the REPL application.
*/
repl(): Promise<ReplImpl>;
/**
* Ignite the Console application.
*/
console(argv: string[], options?: ConsoleOptions): Promise<import("@athenna/artisan").ArtisanImpl>;
/**
* Ignite the Http server application.
*/
httpServer(options?: HttpOptions): Promise<import("@athenna/http").ServerImpl>;
/**
* Ignite the CRON application.
*/
cron(options?: CronOptions): Promise<import("@athenna/cron").CronImpl>;
/**
* Fire the application configuring the env variables file, configuration files
* providers and preload files.
*/
fire(): Promise<void>;
/**
* Verify the Node.js engine version if meets the required
* version to run Athenna Framework.
*/
verifyNodeEngineVersion(): void;
/**
* Set the application handler for uncaught exceptions. Any exception throwed that is
* not catched will be resolved by this handler. Also, if this behavior happens, the error
* will be logged and the application will exit with code "1".
*
* @example
* ```ts
* this.setUncaughtExceptionHandler(error => {
* console.error('UncaughtException:', error)
* })
* ```
*/
setUncaughtExceptionHandler(): void;
/**
* Set the application chdir, change the process.cwd method to return the
* root path where the application root is stored. Also resolve the environment
* where the application is running (JavaScript or TypeScript).
*
* This method will determine if the application is using TypeScript by the meta url.
*
* Let's check this example when application is running in TypeScript environment:
*
* @example
* ```ts
* this.setApplicationRootPath()
*
* console.log(Path.ext()) // ts
* console.log(Path.pwd()) // /Users/jlenon7/Development/Athenna/AthennaIO
* console.log(Path.config(`app.${Path.ext()}`)) // /Users/jlenon7/Development/Athenna/AthennaIO/config/app.ts
* ```
*/
setApplicationRootPath(): void;
/**
* Set the application before path, in all directories of Path class unless
* the nodeModules and nodeModulesBin directories.
*
* @example
* ```ts
* this.setApplicationBeforePath()
*
* console.log(Path.config(`app.${Path.ext()}`)) // /Users/jlenon7/Development/Athenna/AthennaIO/config/build/app.ts
* ```
*/
setApplicationBeforePath(): void;
/**
* Set the env file that the application will use. The env file path will be
* automatically resolved by Athenna (using the NODE_ENV variable) if any
* path is set.
*
* In case path is empty:
* If NODE_ENV variable it's already set the .env.${NODE_ENV} file will be used.
* If not, Athenna will read the .env file and try to find the NODE_ENV value and
* then load the environment variables inside the .env.${NODE_ENV} file. If any
* NODE_ENV value is found in .env or .env.${NODE_ENV} file does not exist, Athenna
* will use the .env file.
*/
setEnvVariablesFile(): void;
/**
* Configure the application signals.
*/
setApplicationSignals(): void;
/**
* Load all the content of the .athennarc.json or athenna property of
* package json inside the "rc" config. .athennarc.json file will always
* be the priority, but if it does not exist, Athenna will try to use
* the "athenna" property of package.json. Also, set app name, app version
* and athenna version variables in env.
*
* @example
* ```ts
* Config.get('rc.providers')
* ```
*/
setRcContentAndAppVars(): Promise<void>;
/**
* Load all the configuration files of some path. Remember that the path
* needs to contains only configuration files (It can be nested inside folders).
*
* Imagine this path:
*
* config/
* user/
* database.ts
* customer/
* database.ts
*
* @example
* ```ts
* await this.setConfigurationFiles()
*
* console.log(Config('user.database.url')) // some-url
* console.log(Config('customer.database.url')) // some-different-url
* ```
*/
setConfigurationFiles(): Promise<void>;
/**
* Register this Ignite instance inside the IoC container.
*/
registerItselfToTheContainer(): void;
/**
* Handle an error turning it pretty and logging as fatal.
*/
handleError(error: any): Promise<never>;
/**
* Parse some version string to the SemverNode type.
*/
private parseVersion;
/**
* Resolve some relative path from the root of the project.
*/
private resolvePath;
}