Skip to main content

@microde/application / MicrodeApplication

Class: MicrodeApplication

Defined in: microde-application.ts:130

Composes modules and coordinates their complete lifecycle.

A Microde application can execute only once. Install all modules before calling serve or run.

Example​

const service = new MicrodeApplication();
service.install((context) => new DatabaseModule(context));

const result = await service.run();
process.exitCode = result.exitCode;

Constructors​

Constructor​

new MicrodeApplication(): MicrodeApplication

Defined in: microde-application.ts:150

Returns​

MicrodeApplication

Accessors​

state​

Get Signature​

get state(): MicrodeApplicationState

Defined in: microde-application.ts:161

The application's current lifecycle state.

Returns​

MicrodeApplicationState

Methods​

bind()​

bind<Consumer, Provider>(consumer, slotName, target): void

Defined in: microde-application.ts:218

Binds one declared relationship slot to an exact installed module.

Type Parameters​

Consumer​

Consumer extends MicrodeModule

Provider​

Provider extends MicrodeModule

Parameters​

consumer​

ModuleHandle<Consumer>

slotName​

string

target​

ModuleHandle<Provider>

Returns​

void


install()​

Call Signature​

install<Module>(id, factory): ModuleHandle<Module>

Defined in: microde-application.ts:172

Creates and installs a module.

Type Parameters​
Module​

Module extends MicrodeModule

Parameters​
id​

string

factory​

(context) => Module

A synchronous factory that receives the module-facing context.

Returns​

ModuleHandle<Module>

The installed module.

Throws​

If called after execution has started, or if another installation is in progress.

Call Signature​

install<Module>(factory): Module

Defined in: microde-application.ts:176

Creates and installs a module.

Type Parameters​
Module​

Module extends MicrodeModule

Parameters​
factory​

(context) => Module

A synchronous factory that receives the module-facing context.

Returns​

Module

The installed module.

Throws​

If called after execution has started, or if another installation is in progress.


panic()​

panic(error?): never

Defined in: microde-application.ts:381

Logs an optional fatal error and terminates the process immediately.

This bypasses the normal module shutdown lifecycle.

Parameters​

error?​

unknown

Returns​

never


run()​

run(main): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:334

Runs an application-level task after all modules have started.

Completion or failure of the task begins orderly application shutdown.

Parameters​

main​

MicrodeMain

Returns​

Promise<MicrodeExecutionResult>


serve()​

serve(): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:325

Serves the application using module completion and stop requests to control its lifetime.

Lifecycle failures are represented in the resolved result so cleanup can finish before the caller receives the outcome. Starting an application more than once returns a rejected promise.

Returns​

Promise<MicrodeExecutionResult>


stop()​

Call Signature​

stop(): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:390

Requests an orderly stop.

Returns​

Promise<MicrodeExecutionResult>

Call Signature​

stop(exitCode): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:392

Requests an orderly stop with a specific exit code.

Parameters​
exitCode​

number

Returns​

Promise<MicrodeExecutionResult>

Call Signature​

stop(error): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:394

Requests an orderly stop caused by an error.

Parameters​
error​

unknown

Returns​

Promise<MicrodeExecutionResult>

Call Signature​

stop(exitCode, error): Promise<MicrodeExecutionResult>

Defined in: microde-application.ts:396

Requests an orderly stop with both an exit code and error.

Parameters​
exitCode​

number

error​

unknown

Returns​

Promise<MicrodeExecutionResult>