@venizia/ignis-docs 0.0.1-9 → 0.0.2
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/{v0.0.1-7-initial-architecture.md → 2025-12-16-initial-architecture.md} +20 -12
- package/wiki/changelogs/2025-12-16-model-repo-datasource-refactor.md +300 -0
- package/wiki/changelogs/2025-12-17-refactor.md +80 -12
- package/wiki/changelogs/2025-12-18-performance-optimizations.md +28 -90
- package/wiki/changelogs/2025-12-18-repository-validation-security.md +101 -297
- package/wiki/changelogs/index.md +20 -8
- package/wiki/changelogs/planned-schema-migrator.md +561 -0
- package/wiki/changelogs/planned-transaction-support.md +216 -0
- package/wiki/changelogs/template.md +123 -0
- package/wiki/get-started/best-practices/api-usage-examples.md +0 -2
- package/wiki/get-started/best-practices/architectural-patterns.md +2 -2
- package/wiki/get-started/best-practices/code-style-standards.md +575 -10
- package/wiki/get-started/best-practices/common-pitfalls.md +5 -3
- package/wiki/get-started/best-practices/contribution-workflow.md +2 -0
- package/wiki/get-started/best-practices/data-modeling.md +91 -34
- package/wiki/get-started/best-practices/security-guidelines.md +3 -1
- package/wiki/get-started/building-a-crud-api.md +3 -3
- 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/persistent.md +350 -378
- package/wiki/get-started/core-concepts/services.md +21 -27
- package/wiki/references/base/bootstrapping.md +789 -0
- package/wiki/references/base/components.md +1 -1
- package/wiki/references/base/dependency-injection.md +95 -2
- package/wiki/references/base/services.md +2 -2
- package/wiki/references/components/authentication.md +4 -3
- package/wiki/references/components/index.md +1 -1
- package/wiki/references/helpers/error.md +2 -2
- package/wiki/references/src-details/boot.md +379 -0
- package/wiki/references/src-details/core.md +2 -2
- package/wiki/changelogs/v0.0.1-8-model-repo-datasource-refactor.md +0 -278
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
# Bootstrapping
|
|
2
|
+
|
|
3
|
+
> **Core Concept**: Automatic artifact discovery and loading during application startup
|
|
4
|
+
|
|
5
|
+
## What is Bootstrapping?
|
|
6
|
+
|
|
7
|
+
Bootstrapping is the process of automatically discovering and loading application artifacts (controllers, services, repositories, datasources) during application initialization. Instead of manually registering each component, the boot system scans your project directory and automatically loads everything that matches configured patterns.
|
|
8
|
+
|
|
9
|
+
## Why Bootstrap?
|
|
10
|
+
|
|
11
|
+
### Without Boot System (Manual Registration)
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
export class Application extends BaseApplication {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(configs);
|
|
17
|
+
|
|
18
|
+
// Manual registration - tedious and error-prone
|
|
19
|
+
this.dataSource(PostgresDataSource);
|
|
20
|
+
this.dataSource(MongoDataSource);
|
|
21
|
+
|
|
22
|
+
this.repository(UserRepository);
|
|
23
|
+
this.repository(ProductRepository);
|
|
24
|
+
this.repository(OrderRepository);
|
|
25
|
+
this.repository(CustomerRepository);
|
|
26
|
+
// ... 50+ more repositories
|
|
27
|
+
|
|
28
|
+
this.service(AuthService);
|
|
29
|
+
this.service(UserService);
|
|
30
|
+
this.service(ProductService);
|
|
31
|
+
// ... 50+ more services
|
|
32
|
+
|
|
33
|
+
this.controller(AuthController);
|
|
34
|
+
this.controller(UserController);
|
|
35
|
+
this.controller(ProductController);
|
|
36
|
+
// ... 50+ more controllers
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Problems:**
|
|
42
|
+
- **Repetitive** - Every new artifact requires manual registration
|
|
43
|
+
- **Error-prone** - Easy to forget registering new artifacts
|
|
44
|
+
- **Maintenance burden** - Constructor grows as application grows
|
|
45
|
+
- **Merge conflicts** - Multiple developers editing same file
|
|
46
|
+
|
|
47
|
+
### With Boot System (Auto-discovery)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
export const appConfigs: IApplicationConfigs = {
|
|
51
|
+
name: 'MyApp',
|
|
52
|
+
bootOptions: {
|
|
53
|
+
datasources: { dirs: ['datasources'] },
|
|
54
|
+
repositories: { dirs: ['repositories'] },
|
|
55
|
+
services: { dirs: ['services'] },
|
|
56
|
+
controllers: { dirs: ['controllers'] }
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export class Application extends BaseApplication {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(appConfigs);
|
|
63
|
+
// That's it! Everything auto-discovered and registered
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Benefits:**
|
|
69
|
+
- ✅ **Convention-based** - Follow naming patterns, framework does the rest
|
|
70
|
+
- ✅ **Scalable** - Add 100 controllers without changing application code
|
|
71
|
+
- ✅ **Clean** - No constructor bloat
|
|
72
|
+
- ✅ **Team-friendly** - No merge conflicts on registration
|
|
73
|
+
|
|
74
|
+
## How It Works
|
|
75
|
+
|
|
76
|
+
### Three-Phase Boot Process
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
1. CONFIGURE → 2. DISCOVER → 3. LOAD
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Phase 1: Configure
|
|
83
|
+
|
|
84
|
+
Each booter configures its discovery patterns:
|
|
85
|
+
- Which directories to scan
|
|
86
|
+
- Which file extensions to match
|
|
87
|
+
- Whether to scan subdirectories
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// ControllerBooter configures itself
|
|
91
|
+
protected override getDefaultDirs(): string[] {
|
|
92
|
+
return ['controllers'];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
protected override getDefaultExtensions(): string[] {
|
|
96
|
+
return ['.controller.js'];
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Phase 2: Discover
|
|
101
|
+
|
|
102
|
+
Booters scan the filesystem for matching files:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Project Root
|
|
106
|
+
├── controllers/
|
|
107
|
+
│ ├── auth.controller.js ✓ discovered
|
|
108
|
+
│ ├── user.controller.js ✓ discovered
|
|
109
|
+
│ └── helpers/
|
|
110
|
+
│ └── validator.js ✗ doesn't match pattern
|
|
111
|
+
├── services/
|
|
112
|
+
│ └── user.service.js ✓ discovered (by ServiceBooter)
|
|
113
|
+
└── repositories/
|
|
114
|
+
└── user.repository.js ✓ discovered (by RepositoryBooter)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Phase 3: Load
|
|
118
|
+
|
|
119
|
+
Booters load discovered classes and bind them to the container:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Pseudo-code of what happens
|
|
123
|
+
for (const file of discoveredFiles) {
|
|
124
|
+
const module = await import(file);
|
|
125
|
+
for (const exported of Object.values(module)) {
|
|
126
|
+
if (isClass(exported)) {
|
|
127
|
+
app.bind({ key: `controllers.${exported.name}` }).toClass(exported);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Boot Options
|
|
134
|
+
|
|
135
|
+
Configure discovery patterns for each artifact type.
|
|
136
|
+
|
|
137
|
+
### Basic Configuration
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const bootOptions: IBootOptions = {
|
|
141
|
+
controllers: {
|
|
142
|
+
dirs: ['controllers'], // where to look
|
|
143
|
+
extensions: ['.controller.js'], // what to match
|
|
144
|
+
isNested: true // scan subdirectories
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Multiple Directories
|
|
150
|
+
|
|
151
|
+
Scan multiple directories for the same artifact type:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const bootOptions: IBootOptions = {
|
|
155
|
+
controllers: {
|
|
156
|
+
dirs: [
|
|
157
|
+
'controllers/private', // admin controllers
|
|
158
|
+
'controllers/public' // public API controllers
|
|
159
|
+
],
|
|
160
|
+
extensions: ['.controller.js'],
|
|
161
|
+
isNested: true
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Multiple Extensions
|
|
167
|
+
|
|
168
|
+
Support both JavaScript and TypeScript:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const bootOptions: IBootOptions = {
|
|
172
|
+
services: {
|
|
173
|
+
dirs: ['services'],
|
|
174
|
+
extensions: ['.service.js', '.service.ts'],
|
|
175
|
+
isNested: true
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Custom Glob Pattern
|
|
181
|
+
|
|
182
|
+
Override default pattern with custom glob:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
const bootOptions: IBootOptions = {
|
|
186
|
+
repositories: {
|
|
187
|
+
// Custom pattern - matches any .repo.js file in data-access subdirectories
|
|
188
|
+
glob: 'data-access/**/*.repo.js'
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Disable Subdirectory Scanning
|
|
194
|
+
|
|
195
|
+
Only scan root level of directory:
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
const bootOptions: IBootOptions = {
|
|
199
|
+
controllers: {
|
|
200
|
+
dirs: ['controllers'],
|
|
201
|
+
extensions: ['.controller.js'],
|
|
202
|
+
isNested: false // only scan controllers/*.controller.js, not subdirs
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Built-in Booters
|
|
208
|
+
|
|
209
|
+
The framework provides four built-in booters:
|
|
210
|
+
|
|
211
|
+
### DatasourceBooter
|
|
212
|
+
|
|
213
|
+
| Setting | Default |
|
|
214
|
+
|---------|---------|
|
|
215
|
+
| Directories | `['datasources']` |
|
|
216
|
+
| Extensions | `['.datasource.js']` |
|
|
217
|
+
| Binding Key | `datasources.{ClassName}` |
|
|
218
|
+
|
|
219
|
+
**Discovers:**
|
|
220
|
+
- `datasources/postgres.datasource.js` → `PostgresDataSource`
|
|
221
|
+
- `datasources/mongo.datasource.js` → `MongoDataSource`
|
|
222
|
+
|
|
223
|
+
### RepositoryBooter
|
|
224
|
+
|
|
225
|
+
| Setting | Default |
|
|
226
|
+
|---------|---------|
|
|
227
|
+
| Directories | `['repositories']` |
|
|
228
|
+
| Extensions | `['.repository.js']` |
|
|
229
|
+
| Binding Key | `repositories.{ClassName}` |
|
|
230
|
+
|
|
231
|
+
**Discovers:**
|
|
232
|
+
- `repositories/user.repository.js` → `UserRepository`
|
|
233
|
+
- `repositories/product/main.repository.js` → `MainRepository`
|
|
234
|
+
|
|
235
|
+
### ServiceBooter
|
|
236
|
+
|
|
237
|
+
| Setting | Default |
|
|
238
|
+
|---------|---------|
|
|
239
|
+
| Directories | `['services']` |
|
|
240
|
+
| Extensions | `['.service.js']` |
|
|
241
|
+
| Binding Key | `services.{ClassName}` |
|
|
242
|
+
|
|
243
|
+
**Discovers:**
|
|
244
|
+
- `services/auth.service.js` → `AuthService`
|
|
245
|
+
- `services/user/profile.service.js` → `ProfileService`
|
|
246
|
+
|
|
247
|
+
### ControllerBooter
|
|
248
|
+
|
|
249
|
+
| Setting | Default |
|
|
250
|
+
|---------|---------|
|
|
251
|
+
| Directories | `['controllers']` |
|
|
252
|
+
| Extensions | `['.controller.js']` |
|
|
253
|
+
| Binding Key | `controllers.{ClassName}` |
|
|
254
|
+
|
|
255
|
+
**Discovers:**
|
|
256
|
+
- `controllers/auth.controller.js` → `AuthController`
|
|
257
|
+
- `controllers/api/user.controller.js` → `UserController`
|
|
258
|
+
|
|
259
|
+
## Execution Order
|
|
260
|
+
|
|
261
|
+
Boot system respects dependency order:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
1. DatasourceBooter → Datasources must be available first
|
|
265
|
+
2. RepositoryBooter → Repositories need datasources
|
|
266
|
+
3. ServiceBooter → Services may use repositories
|
|
267
|
+
4. ControllerBooter → Controllers use services
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
This ensures dependencies are available when artifacts are constructed.
|
|
271
|
+
|
|
272
|
+
## When Boot Runs
|
|
273
|
+
|
|
274
|
+
### Automatic Boot
|
|
275
|
+
|
|
276
|
+
Boot runs automatically during `initialize()` if `bootOptions` is configured:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const app = new Application();
|
|
280
|
+
await app.start(); // initialize() → boot() → start()
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Manual Boot
|
|
284
|
+
|
|
285
|
+
Explicitly control boot execution:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const app = new Application();
|
|
289
|
+
await app.boot({
|
|
290
|
+
phases: ['configure', 'discover', 'load'],
|
|
291
|
+
booters: ['ControllerBooter', 'ServiceBooter'] // only these booters
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Partial Boot
|
|
296
|
+
|
|
297
|
+
Run only specific phases:
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
await app.boot({
|
|
301
|
+
phases: ['discover'] // only discover, don't load
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## File Naming Conventions
|
|
306
|
+
|
|
307
|
+
Follow these conventions for auto-discovery:
|
|
308
|
+
|
|
309
|
+
### Controllers
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
✓ user.controller.js
|
|
313
|
+
✓ auth.controller.js
|
|
314
|
+
✓ api/product.controller.js
|
|
315
|
+
✗ user-ctrl.js // doesn't match pattern
|
|
316
|
+
✗ controller.js // no prefix
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Services
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
✓ user.service.js
|
|
323
|
+
✓ auth.service.js
|
|
324
|
+
✓ business/order.service.js
|
|
325
|
+
✗ user-svc.js // doesn't match pattern
|
|
326
|
+
✗ service.js // no prefix
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Repositories
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
✓ user.repository.js
|
|
333
|
+
✓ product.repository.js
|
|
334
|
+
✓ data/customer.repository.js
|
|
335
|
+
✗ user-repo.js // doesn't match pattern
|
|
336
|
+
✗ repository.js // no prefix
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Datasources
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
✓ postgres.datasource.js
|
|
343
|
+
✓ mongo.datasource.js
|
|
344
|
+
✓ connections/redis.datasource.js
|
|
345
|
+
✗ postgres-ds.js // doesn't match pattern
|
|
346
|
+
✗ datasource.js // no prefix
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Project Structure Examples
|
|
350
|
+
|
|
351
|
+
### Simple Structure
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
src/
|
|
355
|
+
├── datasources/
|
|
356
|
+
│ └── postgres.datasource.js
|
|
357
|
+
├── repositories/
|
|
358
|
+
│ ├── user.repository.js
|
|
359
|
+
│ └── product.repository.js
|
|
360
|
+
├── services/
|
|
361
|
+
│ ├── auth.service.js
|
|
362
|
+
│ └── user.service.js
|
|
363
|
+
└── controllers/
|
|
364
|
+
├── auth.controller.js
|
|
365
|
+
└── user.controller.js
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Boot Config:**
|
|
369
|
+
```typescript
|
|
370
|
+
bootOptions: {
|
|
371
|
+
datasources: { dirs: ['datasources'] },
|
|
372
|
+
repositories: { dirs: ['repositories'] },
|
|
373
|
+
services: { dirs: ['services'] },
|
|
374
|
+
controllers: { dirs: ['controllers'] }
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Feature-based Structure
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
src/
|
|
382
|
+
├── features/
|
|
383
|
+
│ ├── auth/
|
|
384
|
+
│ │ ├── auth.controller.js
|
|
385
|
+
│ │ ├── auth.service.js
|
|
386
|
+
│ │ └── auth.repository.js
|
|
387
|
+
│ └── user/
|
|
388
|
+
│ ├── user.controller.js
|
|
389
|
+
│ ├── user.service.js
|
|
390
|
+
│ └── user.repository.js
|
|
391
|
+
└── datasources/
|
|
392
|
+
└── postgres.datasource.js
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Boot Config:**
|
|
396
|
+
```typescript
|
|
397
|
+
bootOptions: {
|
|
398
|
+
datasources: { dirs: ['datasources'] },
|
|
399
|
+
repositories: { glob: 'features/**/*.repository.js' },
|
|
400
|
+
services: { glob: 'features/**/*.service.js' },
|
|
401
|
+
controllers: { glob: 'features/**/*.controller.js' }
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Layered Structure
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
src/
|
|
409
|
+
├── data/
|
|
410
|
+
│ ├── datasources/
|
|
411
|
+
│ │ └── postgres.datasource.js
|
|
412
|
+
│ └── repositories/
|
|
413
|
+
│ └── user.repository.js
|
|
414
|
+
├── business/
|
|
415
|
+
│ └── services/
|
|
416
|
+
│ └── user.service.js
|
|
417
|
+
└── api/
|
|
418
|
+
└── controllers/
|
|
419
|
+
└── user.controller.js
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**Boot Config:**
|
|
423
|
+
```typescript
|
|
424
|
+
bootOptions: {
|
|
425
|
+
datasources: { dirs: ['data/datasources'] },
|
|
426
|
+
repositories: { dirs: ['data/repositories'] },
|
|
427
|
+
services: { dirs: ['business/services'] },
|
|
428
|
+
controllers: { dirs: ['api/controllers'] }
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Custom Booters
|
|
433
|
+
|
|
434
|
+
Create custom booters for new artifact types:
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
import { BaseArtifactBooter, IBooterOptions } from '@venizia/ignis-boot';
|
|
438
|
+
import { inject } from '@venizia/ignis-inversion';
|
|
439
|
+
|
|
440
|
+
export class MiddlewareBooter extends BaseArtifactBooter {
|
|
441
|
+
constructor(
|
|
442
|
+
@inject({ key: '@app/project_root' }) root: string,
|
|
443
|
+
@inject({ key: '@app/instance' }) private app: IApplication,
|
|
444
|
+
@inject({ key: '@app/boot-options' }) bootOptions: IBootOptions,
|
|
445
|
+
) {
|
|
446
|
+
super({
|
|
447
|
+
scope: MiddlewareBooter.name,
|
|
448
|
+
root,
|
|
449
|
+
artifactOptions: bootOptions.middlewares ?? {}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
protected getDefaultDirs(): string[] {
|
|
454
|
+
return ['middlewares'];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
protected getDefaultExtensions(): string[] {
|
|
458
|
+
return ['.middleware.js'];
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
protected async bind(): Promise<void> {
|
|
462
|
+
for (const cls of this.loadedClasses) {
|
|
463
|
+
this.app.bind({ key: `middlewares.${cls.name}` }).toClass(cls);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Register Custom Booter:**
|
|
470
|
+
|
|
471
|
+
```typescript
|
|
472
|
+
export class Application extends BaseApplication {
|
|
473
|
+
override async initialize() {
|
|
474
|
+
// Register custom booter
|
|
475
|
+
this.booter(MiddlewareBooter);
|
|
476
|
+
|
|
477
|
+
await super.initialize();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## Performance Considerations
|
|
483
|
+
|
|
484
|
+
### Boot Time
|
|
485
|
+
|
|
486
|
+
Boot adds minimal overhead:
|
|
487
|
+
- **Configure phase**: < 1ms per booter
|
|
488
|
+
- **Discover phase**: 10-50ms (depends on filesystem)
|
|
489
|
+
- **Load phase**: 50-200ms (depends on artifact count)
|
|
490
|
+
|
|
491
|
+
**Total**: Typically 100-300ms for medium-sized applications.
|
|
492
|
+
|
|
493
|
+
### Development vs Production
|
|
494
|
+
|
|
495
|
+
Boot is most valuable in **production** where artifact count is high. In **development**, the overhead is negligible.
|
|
496
|
+
|
|
497
|
+
### Optimization Tips
|
|
498
|
+
|
|
499
|
+
1. **Limit nested scanning** - Set `isNested: false` when possible
|
|
500
|
+
2. **Specific patterns** - Use precise glob patterns
|
|
501
|
+
3. **Skip unused booters** - Only enable needed booters
|
|
502
|
+
4. **Pre-compiled bundles** - For serverless, consider bundling
|
|
503
|
+
|
|
504
|
+
## Troubleshooting
|
|
505
|
+
|
|
506
|
+
### Artifacts Not Discovered
|
|
507
|
+
|
|
508
|
+
**Problem:** Created `user.controller.js` but not loaded.
|
|
509
|
+
|
|
510
|
+
**Solutions:**
|
|
511
|
+
1. Check file naming: Must match pattern (e.g., `*.controller.js`)
|
|
512
|
+
2. Check directory: File must be in configured dirs
|
|
513
|
+
3. Check extension: Must match configured extensions
|
|
514
|
+
4. Enable debug logging: See what's discovered
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
// Enable debug logs
|
|
518
|
+
process.env.LOG_LEVEL = 'debug';
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Wrong Binding Order
|
|
522
|
+
|
|
523
|
+
**Problem:** Repository tries to use datasource before it's available.
|
|
524
|
+
|
|
525
|
+
**Solution:** Boot system handles this automatically. Datasources are always loaded before repositories. If you have custom booters, register them in correct order:
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
this.booter(CustomDatasourceBooter);
|
|
529
|
+
this.booter(CustomRepositoryBooter); // after datasource
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Custom Pattern Not Working
|
|
533
|
+
|
|
534
|
+
**Problem:** Custom glob pattern doesn't match files.
|
|
535
|
+
|
|
536
|
+
**Solution:** Test pattern with glob tool:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# From project root
|
|
540
|
+
npx glob "your-pattern/**/*.controller.js"
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
## Best Practices
|
|
544
|
+
|
|
545
|
+
### ✅ DO
|
|
546
|
+
|
|
547
|
+
- Follow naming conventions consistently
|
|
548
|
+
- Use boot system for applications with > 5 artifacts per type
|
|
549
|
+
- Organize files by feature or layer
|
|
550
|
+
- Keep boot options in config file
|
|
551
|
+
- Use debug logging during development
|
|
552
|
+
|
|
553
|
+
### ❌ DON'T
|
|
554
|
+
|
|
555
|
+
- Mix manual and auto registration (choose one approach)
|
|
556
|
+
- Use boot for tiny applications (< 5 total artifacts)
|
|
557
|
+
- Override default patterns without good reason
|
|
558
|
+
- Skip subdirectories if you have nested structure
|
|
559
|
+
- Ignore boot errors (they indicate misconfiguration)
|
|
560
|
+
|
|
561
|
+
## Related Documentation
|
|
562
|
+
|
|
563
|
+
- [Boot Package Reference](/references/src-details/boot.md)
|
|
564
|
+
- [Application Concepts](/get-started/core-concepts/application.md)
|
|
565
|
+
- [Dependency Injection](/references/base/dependency-injection.md)
|
|
566
|
+
- [Building a CRUD API](/get-started/building-a-crud-api.md)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Components
|
|
2
2
|
|
|
3
|
-
Components are reusable, pluggable modules that encapsulate features
|
|
3
|
+
Components are reusable, pluggable modules that encapsulate a group of related features. A component acts as a powerful container for various resources—including providers, services, controllers, repositories, and even entire mini-applications—making it easy to share and integrate complex functionality across projects.
|
|
4
4
|
|
|
5
5
|
> **Deep Dive:** See [Components Reference](../../references/base/components.md) for technical details.
|
|
6
6
|
|
|
@@ -8,9 +8,11 @@ Components are reusable, pluggable modules that encapsulate features like authen
|
|
|
8
8
|
|
|
9
9
|
A component is a class that extends `BaseComponent` and is responsible for:
|
|
10
10
|
|
|
11
|
-
- **Binding Dependencies**: Registering services, controllers, providers, or other resources with the application's dependency injection container.
|
|
11
|
+
- **Binding Dependencies**: Registering services, controllers, repositories, providers, or other resources with the application's dependency injection container.
|
|
12
12
|
- **Configuring Features**: Setting up middlewares, initializing services, or performing any other setup required for the feature to work.
|
|
13
13
|
|
|
14
|
+
A single component can bundle everything needed for a specific domain—for example, an "AuthComponent" might include multiple services for token management, repositories for user data, and controllers for login/signup endpoints, essentially functioning as a plug-and-play mini-application.
|
|
15
|
+
|
|
14
16
|
`Ignis` comes with several built-in components, which you can explore in the [**Components Reference**](../../references/components/) section:
|
|
15
17
|
|
|
16
18
|
- **`AuthenticateComponent`**: Sets up JWT-based authentication.
|