UNPKG

@athenna/core

Version:

One foundation for multiple applications.

199 lines (198 loc) 6.62 kB
/** * @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, WorkerOptions, IgniteOptions, ConsoleOptions, AWSLambdaHandler } from '#src/types'; import { Ioc } from '@athenna/ioc'; import type { ServerImpl } from '@athenna/http'; 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; /** * Holds if Ignite has already been fired. */ hasFired: boolean; /** * Install source maps support if the --enable-source-maps * flag is not set. */ installSourceMaps(): this; /** * 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>; httpServer(options: HttpOptions & { isAWSLambda: true; }): Promise<AWSLambdaHandler>; httpServer(options?: HttpOptions): Promise<ServerImpl>; /** * Ignite the CRON application. */ cron(options?: CronOptions): Promise<import("@athenna/cron").CronImpl>; /** * Ignite the Worker application. */ worker(options?: WorkerOptions): Promise<import("@athenna/queue").WorkerImpl>; /** * Fire the application configuring the env variables file, configuration files * providers and preload files. */ fire(forceIgniteFire?: boolean): 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<void>; /** * Handle an uncaught error turning it pretty and logging as fatal. */ handleUncaughtError(error: any): Promise<void>; /** * Exit the application only if the exitOnError option is true. */ private safeExitOnError; /** * Exit the application only if the exitOnUncaughtError option is true. */ private safeExitOnUncaughtError; /** * Parse some version string to the SemverNode type. */ private parseVersion; /** * Resolve some relative path from the root of the project. */ private resolvePath; }