alepha@docs:~/docs/reference/primitives$
cat $mode.md | pretty1 min read
#$mode
#Import
typescript
1import { $mode } from "alepha";
#Overview
Activate a selective bootstrap mode.
When the environment condition matches, the owning class becomes alepha.target:
the DI graph is pruned to only this class and its transitive dependencies.
Everything else (HTTP server, job scheduler, etc.) is discarded.
Returns true if the mode is active, false otherwise.
#Examples
ts
1import { $mode, $inject } from "alepha"; 2import { DatabaseProvider } from "alepha/orm"; 3 4class DbMigrationMode { 5 db = $inject(DatabaseProvider); 6 7 mode = $mode({ 8 env: "MIGRATE", 9 ready: async () => {10 await this.db.migrate();11 },12 });13}
bash
MIGRATE=true node app.js # runs migrations, then exits
MODE=MIGRATE node app.js # same effect