@venizia/ignis-docs 0.0.1-8 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -0
- package/package.json +2 -2
- package/wiki/changelogs/2025-12-16-initial-architecture.md +145 -0
- package/wiki/changelogs/2025-12-16-model-repo-datasource-refactor.md +300 -0
- package/wiki/changelogs/2025-12-17-refactor.md +90 -0
- package/wiki/changelogs/2025-12-18-performance-optimizations.md +130 -0
- package/wiki/changelogs/2025-12-18-repository-validation-security.md +249 -0
- package/wiki/changelogs/index.md +33 -0
- package/wiki/changelogs/planned-transaction-support.md +216 -0
- package/wiki/changelogs/template.md +123 -0
- package/wiki/get-started/5-minute-quickstart.md +1 -1
- package/wiki/get-started/best-practices/api-usage-examples.md +12 -10
- package/wiki/get-started/best-practices/architectural-patterns.md +2 -2
- package/wiki/get-started/best-practices/common-pitfalls.md +7 -5
- package/wiki/get-started/best-practices/contribution-workflow.md +2 -0
- package/wiki/get-started/best-practices/data-modeling.md +91 -40
- package/wiki/get-started/best-practices/security-guidelines.md +3 -1
- package/wiki/get-started/building-a-crud-api.md +63 -78
- package/wiki/get-started/core-concepts/application.md +72 -3
- package/wiki/get-started/core-concepts/bootstrapping.md +566 -0
- package/wiki/get-started/core-concepts/components.md +4 -2
- package/wiki/get-started/core-concepts/controllers.md +14 -14
- package/wiki/get-started/core-concepts/persistent.md +383 -431
- package/wiki/get-started/core-concepts/services.md +21 -27
- package/wiki/get-started/quickstart.md +1 -1
- package/wiki/references/base/bootstrapping.md +789 -0
- package/wiki/references/base/components.md +1 -1
- package/wiki/references/base/controllers.md +40 -16
- package/wiki/references/base/datasources.md +195 -33
- package/wiki/references/base/dependency-injection.md +98 -5
- package/wiki/references/base/models.md +398 -28
- package/wiki/references/base/repositories.md +475 -22
- package/wiki/references/base/services.md +2 -2
- package/wiki/references/components/authentication.md +228 -10
- package/wiki/references/components/health-check.md +1 -1
- package/wiki/references/components/index.md +1 -1
- package/wiki/references/components/swagger.md +1 -1
- package/wiki/references/helpers/error.md +2 -2
- package/wiki/references/helpers/inversion.md +8 -3
- package/wiki/references/src-details/boot.md +379 -0
- package/wiki/references/src-details/core.md +8 -7
- package/wiki/references/src-details/inversion.md +4 -4
- package/wiki/references/utilities/request.md +16 -7
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
# Bootstrapping API Reference
|
|
2
|
+
|
|
3
|
+
> **API Reference**: Classes, interfaces, and utilities for application bootstrapping
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Interfaces](#interfaces)
|
|
8
|
+
- [Classes](#classes)
|
|
9
|
+
- [Types](#types)
|
|
10
|
+
- [Utilities](#utilities)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Interfaces
|
|
15
|
+
|
|
16
|
+
### IBootableApplication
|
|
17
|
+
|
|
18
|
+
Interface that applications must implement to support bootstrapping.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
interface IBootableApplication {
|
|
22
|
+
bootOptions?: IBootOptions;
|
|
23
|
+
boot(): Promise<IBootReport>;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Member | Type | Description |
|
|
28
|
+
|--------|------|-------------|
|
|
29
|
+
| `bootOptions` | `IBootOptions \| undefined` | Configuration for artifact discovery |
|
|
30
|
+
| `boot()` | `() => Promise<IBootReport>` | Execute boot process |
|
|
31
|
+
|
|
32
|
+
**Example:**
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
export class Application extends BaseApplication implements IBootableApplication {
|
|
36
|
+
bootOptions = {
|
|
37
|
+
controllers: { dirs: ['controllers'] }
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
async boot() {
|
|
41
|
+
const bootstrapper = this.get<Bootstrapper>({ key: 'bootstrapper' });
|
|
42
|
+
return bootstrapper.boot({});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### IBootOptions
|
|
50
|
+
|
|
51
|
+
Configuration for artifact discovery per artifact type.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
interface IBootOptions {
|
|
55
|
+
controllers?: IArtifactOptions;
|
|
56
|
+
services?: IArtifactOptions;
|
|
57
|
+
repositories?: IArtifactOptions;
|
|
58
|
+
datasources?: IArtifactOptions;
|
|
59
|
+
[artifactType: string]: IArtifactOptions | undefined;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Property | Type | Description |
|
|
64
|
+
|----------|------|-------------|
|
|
65
|
+
| `controllers` | `IArtifactOptions \| undefined` | Controller discovery config |
|
|
66
|
+
| `services` | `IArtifactOptions \| undefined` | Service discovery config |
|
|
67
|
+
| `repositories` | `IArtifactOptions \| undefined` | Repository discovery config |
|
|
68
|
+
| `datasources` | `IArtifactOptions \| undefined` | Datasource discovery config |
|
|
69
|
+
| `[key]` | `IArtifactOptions \| undefined` | Custom artifact type config |
|
|
70
|
+
|
|
71
|
+
**Example:**
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const bootOptions: IBootOptions = {
|
|
75
|
+
controllers: {
|
|
76
|
+
dirs: ['controllers/private', 'controllers/public'],
|
|
77
|
+
extensions: ['.controller.js'],
|
|
78
|
+
isNested: true
|
|
79
|
+
},
|
|
80
|
+
services: {
|
|
81
|
+
glob: 'features/**/*.service.js'
|
|
82
|
+
},
|
|
83
|
+
// Custom artifact type
|
|
84
|
+
middlewares: {
|
|
85
|
+
dirs: ['middlewares'],
|
|
86
|
+
extensions: ['.middleware.js']
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### IArtifactOptions
|
|
94
|
+
|
|
95
|
+
Configuration for discovering a specific artifact type.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
interface IArtifactOptions {
|
|
99
|
+
dirs?: string[];
|
|
100
|
+
extensions?: string[];
|
|
101
|
+
isNested?: boolean;
|
|
102
|
+
glob?: string;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| Property | Type | Default | Description |
|
|
107
|
+
|----------|------|---------|-------------|
|
|
108
|
+
| `dirs` | `string[]` | `undefined` | Directories to scan (relative to project root) |
|
|
109
|
+
| `extensions` | `string[]` | `undefined` | File extensions to match (e.g., `['.controller.js']`) |
|
|
110
|
+
| `isNested` | `boolean` | `true` | Scan subdirectories recursively |
|
|
111
|
+
| `glob` | `string` | `undefined` | Custom glob pattern (overrides dirs/extensions) |
|
|
112
|
+
|
|
113
|
+
**Example:**
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const artifactOptions: IArtifactOptions = {
|
|
117
|
+
dirs: ['controllers/v1', 'controllers/v2'],
|
|
118
|
+
extensions: ['.controller.js', '.controller.ts'],
|
|
119
|
+
isNested: true
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Or with custom glob
|
|
123
|
+
const customOptions: IArtifactOptions = {
|
|
124
|
+
glob: 'src/**/api/*.controller.{js,ts}'
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### IBooter
|
|
131
|
+
|
|
132
|
+
Interface that all booters must implement.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
interface IBooter {
|
|
136
|
+
configure?(): Promise<void> | void;
|
|
137
|
+
discover?(): Promise<void> | void;
|
|
138
|
+
load?(): Promise<void> | void;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
| Method | Phase | Description |
|
|
143
|
+
|--------|-------|-------------|
|
|
144
|
+
| `configure()` | Configure | Setup discovery patterns and options |
|
|
145
|
+
| `discover()` | Discover | Scan filesystem for matching artifacts |
|
|
146
|
+
| `load()` | Load | Load classes and bind to container |
|
|
147
|
+
|
|
148
|
+
**Example:**
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
export class CustomBooter implements IBooter {
|
|
152
|
+
async configure() {
|
|
153
|
+
// Setup patterns
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async discover() {
|
|
157
|
+
// Scan filesystem
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async load() {
|
|
161
|
+
// Load and bind classes
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### IBooterOptions
|
|
169
|
+
|
|
170
|
+
Constructor options for booters.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
interface IBooterOptions {
|
|
174
|
+
scope: string;
|
|
175
|
+
root: string;
|
|
176
|
+
artifactOptions: IArtifactOptions;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
| Property | Type | Description |
|
|
181
|
+
|----------|------|-------------|
|
|
182
|
+
| `scope` | `string` | Logger scope (usually class name) |
|
|
183
|
+
| `root` | `string` | Project root directory path |
|
|
184
|
+
| `artifactOptions` | `IArtifactOptions` | Artifact discovery configuration |
|
|
185
|
+
|
|
186
|
+
**Example:**
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
const options: IBooterOptions = {
|
|
190
|
+
scope: 'ControllerBooter',
|
|
191
|
+
root: '/path/to/project',
|
|
192
|
+
artifactOptions: {
|
|
193
|
+
dirs: ['controllers'],
|
|
194
|
+
extensions: ['.controller.js']
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
### IBootExecutionOptions
|
|
202
|
+
|
|
203
|
+
Options for controlling boot execution.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface IBootExecutionOptions {
|
|
207
|
+
phases?: TBootPhase[];
|
|
208
|
+
booters?: string[];
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
| Property | Type | Default | Description |
|
|
213
|
+
|----------|------|---------|-------------|
|
|
214
|
+
| `phases` | `TBootPhase[]` | `['configure', 'discover', 'load']` | Boot phases to execute |
|
|
215
|
+
| `booters` | `string[]` | `undefined` | Specific booters to run (by name) |
|
|
216
|
+
|
|
217
|
+
**Example:**
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
// Run only discover phase
|
|
221
|
+
await bootstrapper.boot({
|
|
222
|
+
phases: ['discover']
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Run only specific booters
|
|
226
|
+
await bootstrapper.boot({
|
|
227
|
+
booters: ['ControllerBooter', 'ServiceBooter']
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Combine both
|
|
231
|
+
await bootstrapper.boot({
|
|
232
|
+
phases: ['configure', 'discover'],
|
|
233
|
+
booters: ['ControllerBooter']
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### IBootstrapper
|
|
240
|
+
|
|
241
|
+
Interface for the bootstrapper orchestrator.
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
interface IBootstrapper {
|
|
245
|
+
boot(opts: IBootExecutionOptions): Promise<IBootReport>;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
| Method | Return | Description |
|
|
250
|
+
|--------|--------|-------------|
|
|
251
|
+
| `boot(opts)` | `Promise<IBootReport>` | Execute boot process with options |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
### IBootReport
|
|
256
|
+
|
|
257
|
+
Report generated after boot completion.
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
interface IBootReport {}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Currently an empty interface, reserved for future enhancements (timing, errors, artifact counts, etc.).
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### IApplication
|
|
268
|
+
|
|
269
|
+
Extended Container interface with application-specific methods.
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
interface IApplication extends Container {
|
|
273
|
+
getProjectRoot(): string;
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
| Method | Return | Description |
|
|
278
|
+
|--------|--------|-------------|
|
|
279
|
+
| `getProjectRoot()` | `string` | Get absolute path to project root |
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Classes
|
|
284
|
+
|
|
285
|
+
### Bootstrapper
|
|
286
|
+
|
|
287
|
+
Orchestrates the boot process by discovering and executing booters.
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
export class Bootstrapper extends BaseHelper implements IBootstrapper
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
#### Constructor
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
constructor(
|
|
297
|
+
@inject({ key: '@app/instance' }) application: IApplication
|
|
298
|
+
)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
| Parameter | Type | Description |
|
|
302
|
+
|-----------|------|-------------|
|
|
303
|
+
| `application` | `IApplication` | Application instance (injected) |
|
|
304
|
+
|
|
305
|
+
#### Methods
|
|
306
|
+
|
|
307
|
+
##### boot()
|
|
308
|
+
|
|
309
|
+
Execute the boot process.
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
async boot(opts: IBootExecutionOptions): Promise<IBootReport>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
| Parameter | Type | Description |
|
|
316
|
+
|-----------|------|-------------|
|
|
317
|
+
| `opts` | `IBootExecutionOptions` | Boot execution options |
|
|
318
|
+
|
|
319
|
+
**Returns:** `Promise<IBootReport>` - Boot completion report
|
|
320
|
+
|
|
321
|
+
**Example:**
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
const bootstrapper = app.get<Bootstrapper>({ key: 'bootstrapper' });
|
|
325
|
+
|
|
326
|
+
// Full boot
|
|
327
|
+
await bootstrapper.boot({});
|
|
328
|
+
|
|
329
|
+
// Partial boot
|
|
330
|
+
await bootstrapper.boot({
|
|
331
|
+
phases: ['discover'],
|
|
332
|
+
booters: ['ControllerBooter']
|
|
333
|
+
});
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
##### discoverBooters() [private]
|
|
337
|
+
|
|
338
|
+
Discovers all booters registered in the application container.
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
private async discoverBooters(): Promise<void>
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Finds all bindings tagged with `'booter'` and instantiates them.
|
|
345
|
+
|
|
346
|
+
##### runPhase() [private]
|
|
347
|
+
|
|
348
|
+
Executes a specific boot phase on all booters.
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
private async runPhase(opts: { phase: TBootPhase; booterNames?: string[] }): Promise<void>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
##### generateReport() [private]
|
|
355
|
+
|
|
356
|
+
Generates boot completion report.
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
private generateReport(): IBootReport
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
### BaseArtifactBooter
|
|
365
|
+
|
|
366
|
+
Abstract base class for creating artifact booters.
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
export abstract class BaseArtifactBooter extends BaseHelper implements IBooter
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### Constructor
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
constructor(opts: IBooterOptions)
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
| Parameter | Type | Description |
|
|
379
|
+
|-----------|------|-------------|
|
|
380
|
+
| `opts` | `IBooterOptions` | Booter configuration |
|
|
381
|
+
|
|
382
|
+
#### Abstract Methods
|
|
383
|
+
|
|
384
|
+
##### getDefaultDirs()
|
|
385
|
+
|
|
386
|
+
Return default directories to scan.
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
protected abstract getDefaultDirs(): string[]
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Example:**
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
protected getDefaultDirs(): string[] {
|
|
396
|
+
return ['controllers'];
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
##### getDefaultExtensions()
|
|
401
|
+
|
|
402
|
+
Return default file extensions to match.
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
protected abstract getDefaultExtensions(): string[]
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Example:**
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
protected getDefaultExtensions(): string[] {
|
|
412
|
+
return ['.controller.js'];
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
##### bind()
|
|
417
|
+
|
|
418
|
+
Bind loaded classes to application container.
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
protected abstract bind(): Promise<void>
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Example:**
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
protected async bind(): Promise<void> {
|
|
428
|
+
for (const cls of this.loadedClasses) {
|
|
429
|
+
this.application.bind({ key: `controllers.${cls.name}` }).toClass(cls);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
#### Implemented Methods
|
|
435
|
+
|
|
436
|
+
##### configure()
|
|
437
|
+
|
|
438
|
+
Configure discovery patterns using defaults or provided options.
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
async configure(): Promise<void>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
##### discover()
|
|
445
|
+
|
|
446
|
+
Scan filesystem for artifacts matching the pattern.
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
async discover(): Promise<void>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
##### load()
|
|
453
|
+
|
|
454
|
+
Load discovered classes and bind them to container.
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
async load(): Promise<void>
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
##### getPattern()
|
|
461
|
+
|
|
462
|
+
Generate glob pattern from artifact options.
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
protected getPattern(): string
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Returns:** Glob pattern string (e.g., `{dir1,dir2}/**/*.{ext1,ext2}`)
|
|
469
|
+
|
|
470
|
+
#### Properties
|
|
471
|
+
|
|
472
|
+
| Property | Type | Description |
|
|
473
|
+
|----------|------|-------------|
|
|
474
|
+
| `root` | `string` | Project root directory |
|
|
475
|
+
| `artifactOptions` | `IArtifactOptions` | Artifact discovery config |
|
|
476
|
+
| `discoveredFiles` | `string[]` | Array of discovered file paths |
|
|
477
|
+
| `loadedClasses` | `TClass<any>[]` | Array of loaded class constructors |
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
### ControllerBooter
|
|
482
|
+
|
|
483
|
+
Built-in booter for discovering controllers.
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
export class ControllerBooter extends BaseArtifactBooter
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Constructor
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
constructor(
|
|
493
|
+
@inject({ key: '@app/project_root' }) root: string,
|
|
494
|
+
@inject({ key: '@app/instance' }) application: IApplication,
|
|
495
|
+
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions
|
|
496
|
+
)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
#### Defaults
|
|
500
|
+
|
|
501
|
+
| Setting | Value |
|
|
502
|
+
|---------|-------|
|
|
503
|
+
| Directories | `['controllers']` |
|
|
504
|
+
| Extensions | `['.controller.js']` |
|
|
505
|
+
| Binding Key | `controllers.{ClassName}` |
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
### ServiceBooter
|
|
510
|
+
|
|
511
|
+
Built-in booter for discovering services.
|
|
512
|
+
|
|
513
|
+
```typescript
|
|
514
|
+
export class ServiceBooter extends BaseArtifactBooter
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
#### Constructor
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
constructor(
|
|
521
|
+
@inject({ key: '@app/project_root' }) root: string,
|
|
522
|
+
@inject({ key: '@app/instance' }) application: IApplication,
|
|
523
|
+
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions
|
|
524
|
+
)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
#### Defaults
|
|
528
|
+
|
|
529
|
+
| Setting | Value |
|
|
530
|
+
|---------|-------|
|
|
531
|
+
| Directories | `['services']` |
|
|
532
|
+
| Extensions | `['.service.js']` |
|
|
533
|
+
| Binding Key | `services.{ClassName}` |
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
### RepositoryBooter
|
|
538
|
+
|
|
539
|
+
Built-in booter for discovering repositories.
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
export class RepositoryBooter extends BaseArtifactBooter
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
#### Constructor
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
constructor(
|
|
549
|
+
@inject({ key: '@app/project_root' }) root: string,
|
|
550
|
+
@inject({ key: '@app/instance' }) application: IApplication,
|
|
551
|
+
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions
|
|
552
|
+
)
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
#### Defaults
|
|
556
|
+
|
|
557
|
+
| Setting | Value |
|
|
558
|
+
|---------|-------|
|
|
559
|
+
| Directories | `['repositories']` |
|
|
560
|
+
| Extensions | `['.repository.js']` |
|
|
561
|
+
| Binding Key | `repositories.{ClassName}` |
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
|
|
565
|
+
### DatasourceBooter
|
|
566
|
+
|
|
567
|
+
Built-in booter for discovering datasources.
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
export class DatasourceBooter extends BaseArtifactBooter
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### Constructor
|
|
574
|
+
|
|
575
|
+
```typescript
|
|
576
|
+
constructor(
|
|
577
|
+
@inject({ key: '@app/project_root' }) root: string,
|
|
578
|
+
@inject({ key: '@app/instance' }) application: IApplication,
|
|
579
|
+
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions
|
|
580
|
+
)
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
#### Defaults
|
|
584
|
+
|
|
585
|
+
| Setting | Value |
|
|
586
|
+
|---------|-------|
|
|
587
|
+
| Directories | `['datasources']` |
|
|
588
|
+
| Extensions | `['.datasource.js']` |
|
|
589
|
+
| Binding Key | `datasources.{ClassName}` |
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
## Types
|
|
594
|
+
|
|
595
|
+
### TBootPhase
|
|
596
|
+
|
|
597
|
+
Boot execution phases.
|
|
598
|
+
|
|
599
|
+
```typescript
|
|
600
|
+
type TBootPhase = 'configure' | 'discover' | 'load'
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**Values:**
|
|
604
|
+
- `'configure'` - Setup phase
|
|
605
|
+
- `'discover'` - File discovery phase
|
|
606
|
+
- `'load'` - Class loading and binding phase
|
|
607
|
+
|
|
608
|
+
### TClass
|
|
609
|
+
|
|
610
|
+
Generic class constructor type.
|
|
611
|
+
|
|
612
|
+
```typescript
|
|
613
|
+
type TClass<T> = TConstructor<T> & { [property: string]: any }
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### TConstructor
|
|
617
|
+
|
|
618
|
+
Constructor function type.
|
|
619
|
+
|
|
620
|
+
```typescript
|
|
621
|
+
type TConstructor<T> = new (...args: any[]) => T
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### TAbstractConstructor
|
|
625
|
+
|
|
626
|
+
Abstract constructor type.
|
|
627
|
+
|
|
628
|
+
```typescript
|
|
629
|
+
type TAbstractConstructor<T> = abstract new (...args: any[]) => T
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Utilities
|
|
635
|
+
|
|
636
|
+
### discoverFiles()
|
|
637
|
+
|
|
638
|
+
Discover files matching a glob pattern.
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
async function discoverFiles(opts: {
|
|
642
|
+
pattern: string;
|
|
643
|
+
root: string;
|
|
644
|
+
}): Promise<string[]>
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
| Parameter | Type | Description |
|
|
648
|
+
|-----------|------|-------------|
|
|
649
|
+
| `pattern` | `string` | Glob pattern to match |
|
|
650
|
+
| `root` | `string` | Root directory for search |
|
|
651
|
+
|
|
652
|
+
**Returns:** `Promise<string[]>` - Array of absolute file paths
|
|
653
|
+
|
|
654
|
+
**Example:**
|
|
655
|
+
|
|
656
|
+
```typescript
|
|
657
|
+
const files = await discoverFiles({
|
|
658
|
+
pattern: 'controllers/**/*.controller.js',
|
|
659
|
+
root: '/path/to/project'
|
|
660
|
+
});
|
|
661
|
+
// ['/path/to/project/controllers/user.controller.js', ...]
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
---
|
|
665
|
+
|
|
666
|
+
### loadClasses()
|
|
667
|
+
|
|
668
|
+
Load class constructors from files.
|
|
669
|
+
|
|
670
|
+
```typescript
|
|
671
|
+
async function loadClasses(opts: {
|
|
672
|
+
files: string[];
|
|
673
|
+
root: string;
|
|
674
|
+
}): Promise<TClass<any>[]>
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
| Parameter | Type | Description |
|
|
678
|
+
|-----------|------|-------------|
|
|
679
|
+
| `files` | `string[]` | Array of file paths to load |
|
|
680
|
+
| `root` | `string` | Project root (for error messages) |
|
|
681
|
+
|
|
682
|
+
**Returns:** `Promise<TClass<any>[]>` - Array of loaded class constructors
|
|
683
|
+
|
|
684
|
+
**Example:**
|
|
685
|
+
|
|
686
|
+
```typescript
|
|
687
|
+
const classes = await loadClasses({
|
|
688
|
+
files: [
|
|
689
|
+
'/path/to/project/controllers/user.controller.js',
|
|
690
|
+
'/path/to/project/controllers/product.controller.js'
|
|
691
|
+
],
|
|
692
|
+
root: '/path/to/project'
|
|
693
|
+
});
|
|
694
|
+
// [UserController, ProductController]
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
### isClass()
|
|
700
|
+
|
|
701
|
+
Type guard to check if value is a class constructor.
|
|
702
|
+
|
|
703
|
+
```typescript
|
|
704
|
+
function isClass<T>(target: any): target is TClass<T>
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
| Parameter | Type | Description |
|
|
708
|
+
|-----------|------|-------------|
|
|
709
|
+
| `target` | `any` | Value to check |
|
|
710
|
+
|
|
711
|
+
**Returns:** `boolean` - True if target is a class constructor
|
|
712
|
+
|
|
713
|
+
**Example:**
|
|
714
|
+
|
|
715
|
+
```typescript
|
|
716
|
+
const module = await import('./user.controller.js');
|
|
717
|
+
|
|
718
|
+
for (const exported of Object.values(module)) {
|
|
719
|
+
if (isClass(exported)) {
|
|
720
|
+
// exported is TClass<any>
|
|
721
|
+
console.log(exported.name); // "UserController"
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
---
|
|
727
|
+
|
|
728
|
+
## Constants
|
|
729
|
+
|
|
730
|
+
### BOOT_PHASES
|
|
731
|
+
|
|
732
|
+
Array of all boot phases in execution order.
|
|
733
|
+
|
|
734
|
+
```typescript
|
|
735
|
+
const BOOT_PHASES: TBootPhase[] = ['configure', 'discover', 'load']
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
**Usage:**
|
|
739
|
+
|
|
740
|
+
```typescript
|
|
741
|
+
import { BOOT_PHASES } from '@venizia/ignis-boot';
|
|
742
|
+
|
|
743
|
+
await bootstrapper.boot({ phases: BOOT_PHASES });
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
## Mixin Functions
|
|
749
|
+
|
|
750
|
+
### BootMixin()
|
|
751
|
+
|
|
752
|
+
Mixin that adds bootable capability to applications.
|
|
753
|
+
|
|
754
|
+
```typescript
|
|
755
|
+
function BootMixin<T extends TMixinTarget<Container>>(
|
|
756
|
+
baseClass: T
|
|
757
|
+
): typeof baseClass & IBootableApplication
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
| Parameter | Type | Description |
|
|
761
|
+
|-----------|------|-------------|
|
|
762
|
+
| `baseClass` | `T extends TMixinTarget<Container>` | Base class to extend |
|
|
763
|
+
|
|
764
|
+
**Returns:** Mixed class implementing `IBootableApplication`
|
|
765
|
+
|
|
766
|
+
**Example:**
|
|
767
|
+
|
|
768
|
+
```typescript
|
|
769
|
+
import { BootMixin } from '@venizia/ignis-boot';
|
|
770
|
+
import { Container } from '@venizia/ignis-inversion';
|
|
771
|
+
|
|
772
|
+
class MyApp extends BootMixin(Container) {
|
|
773
|
+
bootOptions = {
|
|
774
|
+
controllers: { dirs: ['controllers'] }
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const app = new MyApp();
|
|
779
|
+
await app.boot();
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
---
|
|
783
|
+
|
|
784
|
+
## Related Documentation
|
|
785
|
+
|
|
786
|
+
- [Bootstrapping Concepts](/get-started/core-concepts/bootstrapping.md)
|
|
787
|
+
- [Boot Package Reference](/references/src-details/boot.md)
|
|
788
|
+
- [Application Guide](/get-started/core-concepts/application.md)
|
|
789
|
+
- [Dependency Injection](/references/base/dependency-injection.md)
|