Quik Framework :: Bootstrap
- Codename: Berlin
- Version: 0.2.0-beta.76
- License: Check license here
Implements boot hooks and initialization helpers. The module exposes lifecycle hook functions used to start and stop the framework during application boot.
Hook Ordering & Failure Behavior
Lifecycle hooks run in the following order:
BEFORE_INIT->INIT->AFTER_INITBEFORE_BOOT->BOOT->AFTER_BOOTBEFORE_RESET->RESET->AFTER_RESET
Callbacks for each step execute sequentially in registration order. Errors are logged and do not stop the remaining hooks from running.
For long-running applications, AFTER_BOOT is the teardown phase. A bootstrap
restart runs teardown, executes reset hooks, reloads bootstrap setup, and then
boots again from the saved setup options.
Timing Instrumentation
Bootstrap logs timing information for each hook callback and module setup when debug logging is enabled. This helps identify slow boot steps without changing application behavior.
Installation
npm install @quik/bootstrap
Usage
Register lifecycle hooks:
import { onBeforeBoot, onBoot, onAfterBoot } from '@quik/bootstrap';
onBeforeBoot(async () => {
// prepare resources
});
onBoot(async () => {
// start services
});
onAfterBoot(async () => {
// post-boot checks
});
Trigger lifecycle execution:
import { Module } from '@quik/bootstrap';
await Module.setup({
core: { logging, i18n },
modules: [],
flags: {
isCli: false,
startHttpServer: true,
startWebSocketServer: false,
startScheduler: false,
isTest: false
}
});
await Module.init();
await Module.boot();
Restart or stop the runtime in process:
import { BootstrapEvent, BootstrapEvents, restart, shutdown } from '@quik/bootstrap';
await restart();
await shutdown();
BootstrapEvents.emit(BootstrapEvent.RESTART);
API Highlights
onBeforeBoot,onBoot,onAfterBootregister boot lifecycle callbacks.onBeforeInit,onInit,onAfterInitregister init lifecycle callbacks.onBeforeReset,onReset,onAfterResetregister full-reload callbacks.onAction(action, callback)registers by explicit lifecycle enum.Module.setup(options)loads modules and registers hooks.Module.init()runs the INIT procedure.Module.boot()runs the BOOT procedure.restart()performs a full in-process reload from the saved bootstrap setup.shutdown()executes registered teardown hooks once.BootstrapEvents.emit(BootstrapEvent.RESTART)triggers a fire-and-forget restart event.
Testing & Coverage
See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.
API Reference
Generated API documentation is available in the bootstrap API section.