@venizia/ignis-docs 0.0.7 → 0.0.8-0
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/dist/mcp-server/common/paths.d.ts +4 -2
- package/dist/mcp-server/common/paths.d.ts.map +1 -1
- package/dist/mcp-server/common/paths.js +8 -6
- package/dist/mcp-server/common/paths.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.js +7 -7
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.js +3 -3
- package/dist/mcp-server/tools/docs/get-package-overview.tool.d.ts +1 -1
- package/dist/mcp-server/tools/docs/get-package-overview.tool.js +1 -1
- package/package.json +1 -1
- package/wiki/best-practices/api-usage-examples.md +9 -9
- package/wiki/best-practices/architectural-patterns.md +19 -3
- package/wiki/best-practices/architecture-decisions.md +6 -6
- package/wiki/best-practices/code-style-standards/advanced-patterns.md +1 -1
- package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
- package/wiki/best-practices/code-style-standards/function-patterns.md +2 -2
- package/wiki/best-practices/code-style-standards/index.md +2 -2
- package/wiki/best-practices/code-style-standards/naming-conventions.md +1 -1
- package/wiki/best-practices/code-style-standards/route-definitions.md +4 -4
- package/wiki/best-practices/data-modeling.md +1 -1
- package/wiki/best-practices/deployment-strategies.md +1 -1
- package/wiki/best-practices/error-handling.md +2 -2
- package/wiki/best-practices/performance-optimization.md +3 -3
- package/wiki/best-practices/security-guidelines.md +2 -2
- package/wiki/best-practices/troubleshooting-tips.md +1 -1
- package/wiki/{references → extensions}/components/authentication/api.md +12 -20
- package/wiki/{references → extensions}/components/authentication/errors.md +1 -1
- package/wiki/{references → extensions}/components/authentication/index.md +5 -8
- package/wiki/{references → extensions}/components/authentication/usage.md +20 -36
- package/wiki/{references → extensions}/components/authorization/api.md +62 -13
- package/wiki/{references → extensions}/components/authorization/errors.md +12 -7
- package/wiki/{references → extensions}/components/authorization/index.md +93 -6
- package/wiki/{references → extensions}/components/authorization/usage.md +42 -4
- package/wiki/{references → extensions}/components/health-check.md +5 -4
- package/wiki/{references → extensions}/components/index.md +2 -0
- package/wiki/{references → extensions}/components/mail/index.md +1 -1
- package/wiki/{references → extensions}/components/request-tracker.md +1 -1
- package/wiki/{references → extensions}/components/socket-io/api.md +2 -2
- package/wiki/{references → extensions}/components/socket-io/errors.md +2 -0
- package/wiki/{references → extensions}/components/socket-io/index.md +24 -20
- package/wiki/{references → extensions}/components/socket-io/usage.md +2 -2
- package/wiki/{references → extensions}/components/static-asset/api.md +14 -15
- package/wiki/{references → extensions}/components/static-asset/errors.md +3 -1
- package/wiki/{references → extensions}/components/static-asset/index.md +158 -89
- package/wiki/{references → extensions}/components/static-asset/usage.md +8 -5
- package/wiki/{references → extensions}/components/swagger.md +3 -3
- package/wiki/{references → extensions}/components/template/index.md +4 -4
- package/wiki/{references → extensions}/components/template/setup-page.md +1 -1
- package/wiki/{references → extensions}/components/template/single-page.md +1 -1
- package/wiki/{references → extensions}/components/websocket/api.md +7 -6
- package/wiki/{references → extensions}/components/websocket/errors.md +17 -3
- package/wiki/{references → extensions}/components/websocket/index.md +17 -11
- package/wiki/{references → extensions}/components/websocket/usage.md +2 -2
- package/wiki/{references → extensions}/helpers/crypto/index.md +1 -1
- package/wiki/{references → extensions}/helpers/env/index.md +9 -5
- package/wiki/{references → extensions}/helpers/error/index.md +2 -7
- package/wiki/{references → extensions}/helpers/index.md +18 -6
- package/wiki/{references → extensions}/helpers/kafka/admin.md +13 -1
- package/wiki/{references → extensions}/helpers/kafka/consumer.md +28 -28
- package/wiki/{references → extensions}/helpers/kafka/examples.md +19 -19
- package/wiki/{references → extensions}/helpers/kafka/index.md +51 -48
- package/wiki/{references → extensions}/helpers/kafka/producer.md +18 -18
- package/wiki/{references → extensions}/helpers/kafka/schema-registry.md +25 -25
- package/wiki/{references → extensions}/helpers/logger/index.md +2 -2
- package/wiki/{references → extensions}/helpers/queue/index.md +400 -4
- package/wiki/{references → extensions}/helpers/storage/api.md +170 -10
- package/wiki/{references → extensions}/helpers/storage/index.md +44 -8
- package/wiki/{references → extensions}/helpers/template/index.md +1 -1
- package/wiki/{references → extensions}/helpers/testing/index.md +4 -4
- package/wiki/{references → extensions}/helpers/types/index.md +63 -16
- package/wiki/{references → extensions}/helpers/websocket/index.md +1 -1
- package/wiki/extensions/index.md +48 -0
- package/wiki/guides/core-concepts/application/bootstrapping.md +55 -37
- package/wiki/guides/core-concepts/application/index.md +95 -35
- package/wiki/guides/core-concepts/components-guide.md +23 -19
- package/wiki/guides/core-concepts/components.md +34 -10
- package/wiki/guides/core-concepts/dependency-injection.md +99 -34
- package/wiki/guides/core-concepts/grpc-controllers.md +295 -0
- package/wiki/guides/core-concepts/persistent/datasources.md +27 -8
- package/wiki/guides/core-concepts/persistent/models.md +43 -1
- package/wiki/guides/core-concepts/persistent/repositories.md +75 -8
- package/wiki/guides/core-concepts/persistent/transactions.md +38 -8
- package/wiki/guides/core-concepts/{controllers.md → rest-controllers.md} +30 -33
- package/wiki/guides/core-concepts/services.md +19 -5
- package/wiki/guides/get-started/5-minute-quickstart.md +6 -7
- package/wiki/guides/get-started/philosophy.md +1 -1
- package/wiki/guides/index.md +2 -2
- package/wiki/guides/reference/glossary.md +7 -7
- package/wiki/guides/reference/mcp-docs-server.md +1 -1
- package/wiki/guides/tutorials/building-a-crud-api.md +2 -2
- package/wiki/guides/tutorials/complete-installation.md +17 -14
- package/wiki/guides/tutorials/ecommerce-api.md +18 -18
- package/wiki/guides/tutorials/realtime-chat.md +8 -8
- package/wiki/guides/tutorials/testing.md +2 -2
- package/wiki/index.md +4 -3
- package/wiki/references/base/application.md +341 -21
- package/wiki/references/base/bootstrapping.md +43 -13
- package/wiki/references/base/components.md +259 -8
- package/wiki/references/base/controllers.md +556 -253
- package/wiki/references/base/datasources.md +159 -79
- package/wiki/references/base/dependency-injection.md +299 -48
- package/wiki/references/base/filter-system/application-usage.md +18 -2
- package/wiki/references/base/filter-system/array-operators.md +14 -6
- package/wiki/references/base/filter-system/comparison-operators.md +9 -3
- package/wiki/references/base/filter-system/default-filter.md +28 -3
- package/wiki/references/base/filter-system/fields-order-pagination.md +17 -13
- package/wiki/references/base/filter-system/index.md +169 -11
- package/wiki/references/base/filter-system/json-filtering.md +51 -18
- package/wiki/references/base/filter-system/list-operators.md +4 -3
- package/wiki/references/base/filter-system/logical-operators.md +7 -2
- package/wiki/references/base/filter-system/null-operators.md +50 -0
- package/wiki/references/base/filter-system/quick-reference.md +82 -243
- package/wiki/references/base/filter-system/range-operators.md +7 -1
- package/wiki/references/base/filter-system/tips.md +34 -7
- package/wiki/references/base/filter-system/use-cases.md +6 -5
- package/wiki/references/base/grpc-controllers.md +984 -0
- package/wiki/references/base/index.md +32 -24
- package/wiki/references/base/middleware.md +347 -0
- package/wiki/references/base/models.md +390 -46
- package/wiki/references/base/providers.md +14 -14
- package/wiki/references/base/repositories/advanced.md +84 -69
- package/wiki/references/base/repositories/index.md +447 -12
- package/wiki/references/base/repositories/mixins.md +103 -98
- package/wiki/references/base/repositories/relations.md +129 -45
- package/wiki/references/base/repositories/soft-deletable.md +104 -23
- package/wiki/references/base/services.md +94 -14
- package/wiki/references/index.md +12 -10
- package/wiki/references/quick-reference.md +98 -65
- package/wiki/references/utilities/crypto.md +21 -4
- package/wiki/references/utilities/date.md +25 -7
- package/wiki/references/utilities/index.md +26 -24
- package/wiki/references/utilities/jsx.md +54 -54
- package/wiki/references/utilities/module.md +8 -6
- package/wiki/references/utilities/parse.md +16 -9
- package/wiki/references/utilities/performance.md +22 -7
- package/wiki/references/utilities/promise.md +19 -16
- package/wiki/references/utilities/request.md +48 -26
- package/wiki/references/utilities/schema.md +69 -6
- package/wiki/references/utilities/statuses.md +131 -140
- /package/wiki/{references → extensions}/components/mail/api.md +0 -0
- /package/wiki/{references → extensions}/components/mail/errors.md +0 -0
- /package/wiki/{references → extensions}/components/mail/usage.md +0 -0
- /package/wiki/{references → extensions}/components/template/api-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/errors-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/usage-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/cron/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/inversion/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/redis/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/template/single-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/uid/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/websocket/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/worker-thread/index.md +0 -0
- /package/wiki/{references → extensions}/src-details/mcp-server.md +0 -0
|
@@ -17,6 +17,8 @@ Technical reference for `BaseComponent`—the foundation for creating reusable,
|
|
|
17
17
|
| **Encapsulation** | Bundle feature bindings (services, controllers) into single class |
|
|
18
18
|
| **Lifecycle Management** | Auto-called `binding()` method during startup |
|
|
19
19
|
| **Default Bindings** | Self-contained with automatic DI registration |
|
|
20
|
+
| **Idempotent Configure** | `configure()` is safe to call multiple times — runs `binding()` only once |
|
|
21
|
+
| **Controller Transports** | `RestComponent` and `GrpcComponent` handle controller discovery per transport |
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
## Component Directory Structure
|
|
@@ -70,6 +72,23 @@ src/components/auth/
|
|
|
70
72
|
└── sign-up.schema.ts
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
### Controller Transport Component
|
|
76
|
+
|
|
77
|
+
Transport components live under `src/components/controller/` and are instantiated directly by the application during `registerControllers()` — they are **not** registered via `this.component()`.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
src/components/controller/
|
|
81
|
+
├── index.ts # Barrel re-exports (REST only; gRPC excluded from barrel)
|
|
82
|
+
├── rest/
|
|
83
|
+
│ ├── rest.component.ts
|
|
84
|
+
│ └── common/
|
|
85
|
+
│ └── types.ts # IRestComponentConfig, RestBindingKeys
|
|
86
|
+
└── grpc/
|
|
87
|
+
├── grpc.component.ts
|
|
88
|
+
└── common/
|
|
89
|
+
└── types.ts # IGrpcComponentConfig, GrpcBindingKeys
|
|
90
|
+
```
|
|
91
|
+
|
|
73
92
|
|
|
74
93
|
## The `common/` Directory
|
|
75
94
|
|
|
@@ -233,6 +252,16 @@ export * from './controller';
|
|
|
233
252
|
|
|
234
253
|
Abstract class for all components - structures resource binding and lifecycle management.
|
|
235
254
|
|
|
255
|
+
### Class Signature
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
abstract class BaseComponent<ConfigurableOptions extends object = {}>
|
|
259
|
+
extends BaseHelper
|
|
260
|
+
implements IConfigurable<ConfigurableOptions>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`BaseComponent` extends `BaseHelper` (scoped logging via `this.logger`) and implements `IConfigurable` (the `configure()` method).
|
|
264
|
+
|
|
236
265
|
### Constructor Options
|
|
237
266
|
|
|
238
267
|
The `super()` constructor in your component can take the following options:
|
|
@@ -240,14 +269,178 @@ The `super()` constructor in your component can take the following options:
|
|
|
240
269
|
| Option | Type | Description |
|
|
241
270
|
| :--- | :--- | :--- |
|
|
242
271
|
| `scope` | `string` | **Required.** A unique name for the component, typically `MyComponent.name`. Used for logging. |
|
|
243
|
-
| `initDefault` | `{ enable:
|
|
244
|
-
| `bindings` | `Record<string, Binding>` | An object where keys are binding keys and values are `Binding` instances. These are the default services, values, or providers that your component offers. |
|
|
272
|
+
| `initDefault` | `{ enable: false } \| { enable: true; container: Container }` | If `enable` is `true`, the `bindings` defined below will be automatically registered with the provided `container` (usually the application instance) when `configure()` is called — but only if they are not already bound. Defaults to `{ enable: false }`. |
|
|
273
|
+
| `bindings` | `Record<string \| symbol, Binding>` | An object where keys are binding keys and values are `Binding` instances. These are the default services, values, or providers that your component offers. Defaults to `{}`. |
|
|
274
|
+
|
|
275
|
+
### Properties
|
|
276
|
+
|
|
277
|
+
| Property | Type | Access | Description |
|
|
278
|
+
| :--- | :--- | :--- | :--- |
|
|
279
|
+
| `bindings` | `Record<string \| symbol, Binding>` | `protected` | Default bindings the component provides. Can be set in constructor or assigned directly in the constructor body. |
|
|
280
|
+
| `initDefault` | `TInitDefault` | `protected` | Controls whether default bindings are auto-registered to a container. |
|
|
281
|
+
| `isConfigured` | `boolean` | `protected` | Guard flag — prevents `configure()` from running more than once. |
|
|
282
|
+
|
|
283
|
+
### Methods
|
|
284
|
+
|
|
285
|
+
| Method | Signature | Description |
|
|
286
|
+
| :--- | :--- | :--- |
|
|
287
|
+
| `binding()` | `abstract binding(): ValueOrPromise<void>` | **Abstract.** Override this to register services, controllers, and other resources. Called by `configure()`. |
|
|
288
|
+
| `configure(opts?)` | `async configure(opts?: ConfigurableOptions): Promise<void>` | Entry point. Calls `initDefaultBindings()` (if enabled), then `binding()`. Idempotent — skips if already configured. |
|
|
289
|
+
| `initDefaultBindings(opts)` | `protected initDefaultBindings(opts: { container: Container }): void` | Iterates `this.bindings` and registers each into the container if not already bound. |
|
|
245
290
|
|
|
246
291
|
### Lifecycle Flow
|
|
247
292
|
|
|
248
293
|
1. **Application Instantiates Component**: When you call `this.component(MyComponent)` in your application, the DI container creates an instance of your component.
|
|
249
|
-
2. **Constructor Runs**: Your component's constructor calls `super()`, setting up its scope and defining its default `bindings`.
|
|
250
|
-
3. **Application Calls `
|
|
294
|
+
2. **Constructor Runs**: Your component's constructor calls `super()`, setting up its scope and defining its default `bindings`.
|
|
295
|
+
3. **Application Calls `configure()`**: During the `registerComponents` phase, the application resolves each component and calls `configure()`.
|
|
296
|
+
4. **`configure()` Executes**: Checks `isConfigured` guard (idempotent). If `initDefault.enable` is `true`, registers default bindings into the container. Then calls `binding()`.
|
|
297
|
+
5. **`binding()` Runs**: Your override registers controllers, services, reads options from the container, and performs any additional setup.
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
## Controller Transport Components
|
|
301
|
+
|
|
302
|
+
Controller transport components are a special category. Unlike regular components registered via `this.component()`, transport components are instantiated and configured directly by `BaseApplication.registerControllers()`. They are responsible for discovering controller bindings and mounting them onto the application router.
|
|
303
|
+
|
|
304
|
+
### Transport Configuration
|
|
305
|
+
|
|
306
|
+
The application config `transports` controls which transports are enabled. Defaults to `['rest']`.
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// In your application constructor
|
|
310
|
+
super({
|
|
311
|
+
scope: MyApplication.name,
|
|
312
|
+
config: {
|
|
313
|
+
// ...
|
|
314
|
+
transports: [ControllerTransports.REST, ControllerTransports.GRPC],
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
The `ControllerTransports` constants:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
export class ControllerTransports {
|
|
323
|
+
static readonly REST = 'rest';
|
|
324
|
+
static readonly GRPC = 'grpc';
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### How `registerControllers()` Works
|
|
329
|
+
|
|
330
|
+
During the application lifecycle, `registerControllers()` iterates the configured transports and creates the corresponding component:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
// Simplified from BaseApplication.registerControllers()
|
|
334
|
+
const transports = this.configs.transports ?? [ControllerTransports.REST];
|
|
335
|
+
|
|
336
|
+
for (const transport of transports) {
|
|
337
|
+
switch (transport) {
|
|
338
|
+
case ControllerTransports.REST: {
|
|
339
|
+
const restComponent = new RestComponent(this);
|
|
340
|
+
await restComponent.configure();
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case ControllerTransports.GRPC: {
|
|
344
|
+
const grpcComponent = new GrpcComponent(this);
|
|
345
|
+
await grpcComponent.configure();
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
If gRPC controllers are discovered but the `'grpc'` transport is not in the `transports` config, the application logs an error warning for each one.
|
|
353
|
+
|
|
354
|
+
### `RestComponent`
|
|
355
|
+
|
|
356
|
+
**File:** `packages/core/src/components/controller/rest/rest.component.ts`
|
|
357
|
+
|
|
358
|
+
Discovers all controller bindings tagged with `BindingNamespaces.CONTROLLER`, skips any whose metadata has `transport === ControllerTransports.GRPC`, and configures the rest as REST controllers.
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
export class RestComponent extends BaseComponent {
|
|
362
|
+
constructor(private application: BaseApplication) {
|
|
363
|
+
super({
|
|
364
|
+
scope: RestComponent.name,
|
|
365
|
+
initDefault: { enable: true, container: application },
|
|
366
|
+
bindings: {
|
|
367
|
+
[RestBindingKeys.REST_COMPONENT_OPTIONS]: Binding.bind<IRestComponentConfig>({
|
|
368
|
+
key: RestBindingKeys.REST_COMPONENT_OPTIONS,
|
|
369
|
+
}).toValue(DEFAULT_OPTIONS),
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
override async binding(): Promise<void> { /* ... */ }
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Binding loop:**
|
|
379
|
+
|
|
380
|
+
1. Fetches all controller bindings not yet configured (tracked via a `Set<string>`).
|
|
381
|
+
2. For each binding, reads controller metadata from `MetadataRegistry`.
|
|
382
|
+
3. Skips bindings with `transport === ControllerTransports.GRPC`.
|
|
383
|
+
4. Validates that `metadata.path` is present (throws if missing).
|
|
384
|
+
5. Resolves the controller instance from the DI container, calls `instance.configure()`, and mounts it: `router.route(metadata.path, instance.getRouter())`.
|
|
385
|
+
6. Re-fetches bindings after each configure to pick up dynamically added controllers.
|
|
386
|
+
|
|
387
|
+
**Config types:**
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
export interface IRestComponentConfig {}
|
|
391
|
+
|
|
392
|
+
export class RestBindingKeys {
|
|
393
|
+
static readonly REST_COMPONENT_OPTIONS = '@app/rest/options';
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### `GrpcComponent`
|
|
398
|
+
|
|
399
|
+
**File:** `packages/core/src/components/controller/grpc/grpc.component.ts`
|
|
400
|
+
|
|
401
|
+
Discovers all controller bindings tagged with `BindingNamespaces.CONTROLLER`, skips any whose metadata does **not** have `transport === ControllerTransports.GRPC`, and configures gRPC controllers.
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
export class GrpcComponent extends BaseComponent {
|
|
405
|
+
constructor(private application: BaseApplication) {
|
|
406
|
+
super({
|
|
407
|
+
scope: GrpcComponent.name,
|
|
408
|
+
initDefault: { enable: true, container: application },
|
|
409
|
+
bindings: {
|
|
410
|
+
[GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({
|
|
411
|
+
key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,
|
|
412
|
+
}).toValue(DEFAULT_OPTIONS),
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
override async binding(): Promise<void> { /* ... */ }
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**Binding loop** (same dynamic re-fetch pattern as `RestComponent`):
|
|
422
|
+
|
|
423
|
+
1. Fetches all controller bindings not yet configured.
|
|
424
|
+
2. Skips bindings with `transport !== ControllerTransports.GRPC`.
|
|
425
|
+
3. Validates `metadata.path` is present.
|
|
426
|
+
4. Resolves the gRPC controller instance. Skips if the instance has no `service` definition (logs a warning).
|
|
427
|
+
5. Sets `instance.basePath` from the application's project configs.
|
|
428
|
+
6. Calls `instance.configure()` and mounts: `router.route(metadata.path, instance.getRouter())`.
|
|
429
|
+
7. Re-fetches bindings to pick up dynamically added controllers.
|
|
430
|
+
|
|
431
|
+
**Config types:**
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
export interface IGrpcComponentConfig {
|
|
435
|
+
interceptors?: unknown[];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export class GrpcBindingKeys {
|
|
439
|
+
static readonly GRPC_COMPONENT_OPTIONS = '@app/grpc/options';
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
> **Note:** `GrpcComponent` is excluded from the barrel export at `src/components/controller/index.ts`. Import it directly from `@venizia/ignis/components/controller/grpc` if needed.
|
|
251
444
|
|
|
252
445
|
|
|
253
446
|
## Component Implementation Patterns
|
|
@@ -420,6 +613,62 @@ override binding(): ValueOrPromise<void> {
|
|
|
420
613
|
}
|
|
421
614
|
```
|
|
422
615
|
|
|
616
|
+
### Component without `initDefault` (Manual Binding Assignment)
|
|
617
|
+
|
|
618
|
+
Some components skip `initDefault` and assign `this.bindings` directly in the constructor body:
|
|
619
|
+
|
|
620
|
+
```typescript
|
|
621
|
+
// src/components/swagger/component.ts
|
|
622
|
+
export class SwaggerComponent extends BaseComponent {
|
|
623
|
+
constructor(
|
|
624
|
+
@inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,
|
|
625
|
+
) {
|
|
626
|
+
super({ scope: SwaggerComponent.name });
|
|
627
|
+
|
|
628
|
+
this.bindings = {
|
|
629
|
+
[SwaggerBindingKeys.SWAGGER_OPTIONS]: Binding.bind<ISwaggerOptions>({
|
|
630
|
+
key: SwaggerBindingKeys.SWAGGER_OPTIONS,
|
|
631
|
+
}).toValue(DEFAULT_SWAGGER_OPTIONS),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
override async binding() {
|
|
636
|
+
// Read options, configure OpenAPI doc endpoint, UI endpoint, etc.
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
In this pattern, `initDefault` defaults to `{ enable: false }`, so the bindings are defined but not auto-registered. The component manages its own option reading and setup in `binding()`.
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
## Built-in Components
|
|
645
|
+
|
|
646
|
+
### Registered via `this.component()` (Standard Components)
|
|
647
|
+
|
|
648
|
+
| Component | Key Features |
|
|
649
|
+
|-----------|-------------|
|
|
650
|
+
| **HealthCheckComponent** | `GET /health` (default path, configurable). Registers `HealthCheckController` with `GET /` and `POST /ping` endpoints. |
|
|
651
|
+
| **SwaggerComponent** | OpenAPI doc at `/doc/openapi.json`, UI at `/doc/explorer` (Scalar by default, Swagger UI also supported). Auto-populates app info and server URL. Registers JWT and Basic security schemes. |
|
|
652
|
+
| **AuthenticateComponent** | JWT and/or Basic auth strategies. Optional auth controller (`signIn`/`signUp`). Token services (`JWTTokenService`, `BasicTokenService`). |
|
|
653
|
+
| **AuthorizationComponent** | Casbin-based RBAC, permission mapping, `authorize()` middleware. |
|
|
654
|
+
| **RequestTrackerComponent** | Registers Hono `requestId()` middleware and a `RequestSpyMiddleware` for `x-request-id` header tracking and request body parsing. |
|
|
655
|
+
|
|
656
|
+
### Excluded from Barrel (Import Directly)
|
|
657
|
+
|
|
658
|
+
| Component | Import Path | Key Features |
|
|
659
|
+
|-----------|-------------|-------------|
|
|
660
|
+
| **StaticAssetComponent** | `@venizia/ignis/components/static-asset` | File upload/download CRUD, MinIO/Disk storage. |
|
|
661
|
+
| **MailComponent** | `@venizia/ignis/components/mail` | Nodemailer/Mailgun transporters, Direct/BullMQ/InternalQueue executors. |
|
|
662
|
+
| **SocketIOComponent** | `@venizia/ignis/components/socket-io` | Socket.IO server with Redis adapter for horizontal scaling. |
|
|
663
|
+
| **WebSocketComponent** | `@venizia/ignis/components/websocket` | WebSocket support. |
|
|
664
|
+
|
|
665
|
+
### Controller Transport Components (Not Registered via `this.component()`)
|
|
666
|
+
|
|
667
|
+
| Component | When Used |
|
|
668
|
+
|-----------|-----------|
|
|
669
|
+
| **RestComponent** | Instantiated by `registerControllers()` when `transports` includes `'rest'` (the default). Discovers and mounts REST controllers. |
|
|
670
|
+
| **GrpcComponent** | Instantiated by `registerControllers()` when `transports` includes `'grpc'`. Discovers and mounts gRPC controllers (ConnectRPC over HTTP). |
|
|
671
|
+
|
|
423
672
|
|
|
424
673
|
## Exposing and Consuming Component Options
|
|
425
674
|
|
|
@@ -505,6 +754,7 @@ override binding(): ValueOrPromise<void> {
|
|
|
505
754
|
| **Validation** | Validate required options in `binding()` |
|
|
506
755
|
| **Logging** | Log binding activity with structured messages |
|
|
507
756
|
| **Scope** | Always set `scope: ComponentName.name` |
|
|
757
|
+
| **Idempotency** | `configure()` is already idempotent via `isConfigured` guard — no need to add your own |
|
|
508
758
|
|
|
509
759
|
|
|
510
760
|
## Quick Reference Template
|
|
@@ -588,12 +838,13 @@ export * from './controller';
|
|
|
588
838
|
- [Creating Components](/guides/core-concepts/components-guide) - Build your own components
|
|
589
839
|
- [Application](/guides/core-concepts/application/) - Registering components
|
|
590
840
|
- [Dependency Injection](/guides/core-concepts/dependency-injection) - Component bindings
|
|
841
|
+
- [gRPC Controllers](/references/base/grpc-controllers) - gRPC controller reference
|
|
591
842
|
|
|
592
843
|
- **Built-in Components:**
|
|
593
|
-
- [Authentication Component](/
|
|
594
|
-
- [Health Check Component](/
|
|
595
|
-
- [Swagger Component](/
|
|
596
|
-
- [Socket.IO Component](/
|
|
844
|
+
- [Authentication Component](/extensions/components/authentication/) - JWT authentication
|
|
845
|
+
- [Health Check Component](/extensions/components/health-check) - Health endpoints
|
|
846
|
+
- [Swagger Component](/extensions/components/swagger) - API documentation
|
|
847
|
+
- [Socket.IO Component](/extensions/components/socket-io/) - WebSocket support
|
|
597
848
|
|
|
598
849
|
- **Best Practices:**
|
|
599
850
|
- [Architectural Patterns](/best-practices/architectural-patterns) - Component design patterns
|