Skip to content

Documentation / @andrew_l/app / AppDefinition

Interface: AppDefinition<P, S, M, RuntimeContext, EntryContext, SetupContext> ​

Shape of an application — name, typed props, lifecycle hooks, and optional methods.

Extended by ​

Type Parameters ​

P ​

P extends ObjectPropsOptions = { }

S ​

S extends Record<string, any> = { }

M ​

M extends Record<string, AnyFunction> = { }

RuntimeContext ​

RuntimeContext extends RuntimeContext = RuntimeContext<S & M>

EntryContext ​

EntryContext extends EntryContext = EntryContext<S & M>

SetupContext ​

SetupContext extends SetupContext = SetupContext<M>

Properties ​

description? ​

optional description: string

Describe what your application does


filePath? ​

optional filePath: null | string

Path to the file where this definition exports default Usually you should not use this option, because it tracks automatically


logger? ​

optional logger: false | Logger | (definition) => Logger

Logger instance or constructor function


methods? ​

optional methods: M & ThisType<RuntimeContext>

Custom methods which will be available under this context


name ​

name: string

Name of your awesome application


props? ​

optional props: P

Props options to be parsed from cli arguments of env variables

Methods ​

entry()? ​

optional entry(this, props): any

Entry function that will be called each time when application starts

Parameters ​

this ​

EntryContext

props ​

ExtractPropTypes<P>

Returns ​

any


setup()? ​

optional setup(this, props): Awaitable<S>

Setup function to initialize application. Will be called once

Parameters ​

this ​

SetupContext

props ​

ExtractPropTypes<P>

Returns ​

Awaitable<S>


shutdown()? ​

optional shutdown(this, props): Awaitable<void>

Shutdown function that will be called before application/process graceful shutdown

Parameters ​

this ​

RuntimeContext

props ​

ExtractPropTypes<P>

Returns ​

Awaitable<void>


stop()? ​

optional stop(this, props): Awaitable<void>

Stop function that will be called each time when application stops

Parameters ​

this ​

RuntimeContext

props ​

ExtractPropTypes<P>

Returns ​

Awaitable<void>