
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@loopback/boot
Advanced tools
A convention based project Bootstrapper and Booters for LoopBack Applications
A Booter is a Class that can be bound to an Application and is called to perform a task before the Application is started. A Booter may have multiple phases to complete its task. The task for a convention based Booter is to discover and bind Artifacts (Controllers, Repositories, Models, etc.).
An example task of a Booter may be to discover and bind all artifacts of a given type.
A Bootstrapper is needed to manage the Booters and execute them. This is
provided in this package. For ease of use, everything needed is packages using a
BootMixin. This Mixin will add convenience methods such as boot and booter,
as well as properties needed for Bootstrapper such as projectRoot. The Mixin
also adds the BootComponent to your Application which binds the
Bootstrapper and default Booters made available by this package.
$ npm i @loopback/boot
import {Application} from '@loopback/core';
import {BootMixin, Booter, Binding} from '@loopback/boot';
class BootApp extends BootMixin(Application) {}
const app = new BootApp();
app.projectRoot = __dirname;
await app.boot();
await app.start();
List of Options available on BootOptions Object.
| Option | Type | Description |
|---|---|---|
controllers | ArtifactOptions | ControllerBooter convention options |
repositories | ArtifactOptions | RepositoryBooter convention options |
| Options | Type | Description |
|---|---|---|
dirs | string | string[] | Paths relative to projectRoot to look in for Artifact |
extensions | string | string[] | File extensions to match for Artifact |
nested | boolean | Look in nested directories in dirs for Artifact |
glob | string | A glob pattern string. This takes precedence over above 3 options (which are used to make a glob pattern). |
Experimental support. May be removed or changed in a non-compatible way in future without warning
To use BootExecOptions you must directly call bootstrapper.boot() and pass
in BootExecOptions. app.boot() provided by BootMixin does not take any
paramters.
const bootstrapper: Bootstrapper = await this.get(
BootBindings.BOOTSTRAPPER_KEY,
);
const execOptions: BootExecOptions = {
booters: [MyBooter1, MyBooter2],
filter: {
phases: ['configure', 'discover'],
},
};
const ctx = bootstrapper.boot(execOptions);
You can pass in the BootExecOptions object with the following properties:
| Property | Type | Description |
|---|---|---|
booters | Constructor<Booter>[] | Array of Booters to bind before running boot() |
filter.booters | string[] | Names of Booter classes that should be run |
filter.phases | string[] | Names of Booter phases to run |
Discovers and binds Controller Classes using app.controller().
The Options for this can be passed via BootOptions when calling
app.boot(options:BootOptions).
The options for this are passed in a controllers object on BootOptions.
Available Options on the controllers object on BootOptions are as follows:
| Options | Type | Default | Description |
|---|---|---|---|
dirs | string | string[] | ['controllers'] | Paths relative to projectRoot to look in for Controller artifacts |
extensions | string | string[] | ['.controller.js'] | File extensions to match for Controller artifacts |
nested | boolean | true | Look in nested directories in dirs for Controller artifacts |
glob | string | A glob pattern string. This takes precendence over above 3 options (which are used to make a glob pattern). |
Discovers and binds Repository Classes using app.repository() (Application
must use RepositoryMixin from @loopback/repository).
The Options for this can be passed via BootOptions when calling
app.boot(options:BootOptions).
The options for this are passed in a repositories object on BootOptions.
Available Options on the repositories object on BootOptions are as follows:
| Options | Type | Default | Description |
|---|---|---|---|
dirs | string | string[] | ['repositories'] | Paths relative to projectRoot to look in for Repository artifacts |
extensions | string | string[] | ['.repository.js'] | File extensions to match for Repository artifacts |
nested | boolean | true | Look in nested directories in dirs for Repository artifacts |
glob | string | A glob pattern string. This takes precedence over above 3 options (which are used to make a glob pattern). |
Run npm test from the root folder.
See all contributors.
MIT
FAQs
A collection of Booters for LoopBack 4 Applications
The npm package @loopback/boot receives a total of 21,734 weekly downloads. As such, @loopback/boot popularity was classified as popular.
We found that @loopback/boot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.