Class App<T>

This is the smallest available application abstraction in Deepkit.

It is based on a module and executes registered CLI controllers in execute.

@deepkit/framework extends that with a more powerful Application class, that contains also HTTP and RPC controllers.

You can use this class for more integrated unit-tests.

Type Parameters

Hierarchy

  • App

Constructors

Properties

appModule: AppModule<T, any>
envConfigLoader?: EnvConfigLoader
serviceContainer: ServiceContainer

Methods

  • Parameters

    • config: Partial<ExtractClassType<T["config"]>>

    Returns App<T>

  • Type Parameters

    • T extends EventToken<any, T>

    Parameters

    • eventToken: T
    • event: EventOfEventToken<T>
    • Optional injector: InjectorContext

    Returns Promise<void>

  • Parameters

    • argv: string[]
    • binPaths: string[] = []

    Returns Promise<number>

  • Type Parameters

    • T

    Parameters

    • Optional token: string | number | bigint | boolean | symbol | RegExp | TypeNever | TypeAny | TypeUnknown | TypeVoid | TypeObject | TypeString | TypeNumber | TypeBoolean | TypeBigInt | TypeSymbol | TypeNull | TypeUndefined | TypeLiteral | TypeTemplateLiteral | TypeParameter | TypeFunction | TypeMethod | TypeProperty | TypePromise | TypeClass | TypeEnum | TypeEnumMember | TypeUnion | TypeIntersection | TypeArray | TypeObjectLiteral | TypeIndexSignature | TypePropertySignature | TypeMethodSignature | TypeTypeParameter | TypeInfer | TypeTuple | TypeTupleMember | TypeRest | TypeRegexp | Packed | T | ClassType<T> | AbstractClassType<T>
    • Optional moduleOrClass: AppModule<any, any> | ClassType<AppModule<any, any>>

    Returns ResolveToken<T>

  • Type Parameters

    • T extends EventToken<any, T>

    • DEPS extends any[]

    Parameters

    • eventToken: T
    • callback: EventListenerCallback<T["event"]>
    • order: number = 0

    Returns App<T>

  • Loads environment variables and optionally reads from .env files in order to find matching configuration options in your application and modules in order to set their values.

    Prefixing ENV variables is encouraged to avoid collisions and by default a prefix of APP_ is used Example:

    APP_databaseUrl="mongodb://localhost/mydb"

    new App({}).loadConfigFromEnvVariables('APP_').run();

    envFilePath can be either an absolute or relative path. For relative paths the first folder with a package.json starting from process.cwd() upwards is picked.

    So if you use 'local.env' make sure a 'local.env' file is located beside your 'package.json'.

    Returns

    Parameters

    • Optional options: EnvConfigOptions

      Configuration options for retrieving configuration from env

    Returns App<T>

  • Loads a JSON encoded environment variable and applies its content to the configuration.

    Example:

    APP_CONFIG={'databaseUrl": "mongodb://localhost/mydb", "moduleA": {"foo": "bar'}}

    new App().run().loadConfigFromEnvVariable('APP_CONFIG').run();

    Parameters

    • variableName: string = 'APP_CONFIG'

    Returns App<T>

  • Allows to change the module after the configuration has been loaded, right before the application bootstraps.

    Parameters

    • Rest ...args: [callback: ((module: AppModule<T, any>, config: any) => void)]

    Returns App<T>

Generated using TypeDoc