@venizia/ignis-docs 0.0.5 → 0.0.6-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.
Files changed (123) hide show
  1. package/package.json +1 -1
  2. package/wiki/best-practices/architectural-patterns.md +0 -2
  3. package/wiki/best-practices/architecture-decisions.md +0 -8
  4. package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
  5. package/wiki/best-practices/code-style-standards/index.md +0 -1
  6. package/wiki/best-practices/code-style-standards/tooling.md +0 -3
  7. package/wiki/best-practices/contribution-workflow.md +12 -12
  8. package/wiki/best-practices/index.md +4 -14
  9. package/wiki/best-practices/performance-optimization.md +3 -3
  10. package/wiki/best-practices/security-guidelines.md +2 -2
  11. package/wiki/best-practices/troubleshooting-tips.md +1 -1
  12. package/wiki/guides/core-concepts/application/bootstrapping.md +6 -7
  13. package/wiki/guides/core-concepts/components-guide.md +1 -1
  14. package/wiki/guides/core-concepts/components.md +2 -2
  15. package/wiki/guides/core-concepts/dependency-injection.md +4 -5
  16. package/wiki/guides/core-concepts/persistent/datasources.md +4 -5
  17. package/wiki/guides/core-concepts/services.md +1 -1
  18. package/wiki/guides/get-started/5-minute-quickstart.md +4 -5
  19. package/wiki/guides/get-started/philosophy.md +12 -24
  20. package/wiki/guides/index.md +2 -9
  21. package/wiki/guides/reference/mcp-docs-server.md +13 -13
  22. package/wiki/guides/tutorials/building-a-crud-api.md +10 -10
  23. package/wiki/guides/tutorials/complete-installation.md +11 -12
  24. package/wiki/guides/tutorials/ecommerce-api.md +3 -3
  25. package/wiki/guides/tutorials/realtime-chat.md +6 -6
  26. package/wiki/guides/tutorials/testing.md +4 -5
  27. package/wiki/index.md +8 -14
  28. package/wiki/references/base/bootstrapping.md +0 -3
  29. package/wiki/references/base/components.md +2 -2
  30. package/wiki/references/base/controllers.md +0 -1
  31. package/wiki/references/base/datasources.md +1 -1
  32. package/wiki/references/base/dependency-injection.md +2 -2
  33. package/wiki/references/base/filter-system/default-filter.md +2 -3
  34. package/wiki/references/base/filter-system/index.md +1 -1
  35. package/wiki/references/base/filter-system/quick-reference.md +0 -14
  36. package/wiki/references/base/middlewares.md +0 -8
  37. package/wiki/references/base/providers.md +0 -9
  38. package/wiki/references/base/repositories/advanced.md +1 -1
  39. package/wiki/references/base/repositories/mixins.md +2 -3
  40. package/wiki/references/base/services.md +0 -1
  41. package/wiki/references/components/authentication/api.md +444 -0
  42. package/wiki/references/components/authentication/errors.md +177 -0
  43. package/wiki/references/components/authentication/index.md +571 -0
  44. package/wiki/references/components/authentication/usage.md +781 -0
  45. package/wiki/references/components/health-check.md +292 -103
  46. package/wiki/references/components/index.md +14 -12
  47. package/wiki/references/components/mail/api.md +505 -0
  48. package/wiki/references/components/mail/errors.md +176 -0
  49. package/wiki/references/components/mail/index.md +535 -0
  50. package/wiki/references/components/mail/usage.md +404 -0
  51. package/wiki/references/components/request-tracker.md +229 -25
  52. package/wiki/references/components/socket-io/api.md +1051 -0
  53. package/wiki/references/components/socket-io/errors.md +119 -0
  54. package/wiki/references/components/socket-io/index.md +410 -0
  55. package/wiki/references/components/socket-io/usage.md +322 -0
  56. package/wiki/references/components/static-asset/api.md +261 -0
  57. package/wiki/references/components/static-asset/errors.md +89 -0
  58. package/wiki/references/components/static-asset/index.md +617 -0
  59. package/wiki/references/components/static-asset/usage.md +364 -0
  60. package/wiki/references/components/swagger.md +390 -110
  61. package/wiki/references/components/template/api-page.md +125 -0
  62. package/wiki/references/components/template/errors-page.md +100 -0
  63. package/wiki/references/components/template/index.md +104 -0
  64. package/wiki/references/components/template/setup-page.md +134 -0
  65. package/wiki/references/components/template/single-page.md +132 -0
  66. package/wiki/references/components/template/usage-page.md +127 -0
  67. package/wiki/references/components/websocket/api.md +508 -0
  68. package/wiki/references/components/websocket/errors.md +123 -0
  69. package/wiki/references/components/websocket/index.md +453 -0
  70. package/wiki/references/components/websocket/usage.md +475 -0
  71. package/wiki/references/helpers/cron/index.md +224 -0
  72. package/wiki/references/helpers/crypto/index.md +537 -0
  73. package/wiki/references/helpers/env/index.md +214 -0
  74. package/wiki/references/helpers/error/index.md +232 -0
  75. package/wiki/references/helpers/index.md +16 -15
  76. package/wiki/references/helpers/inversion/index.md +608 -0
  77. package/wiki/references/helpers/logger/index.md +600 -0
  78. package/wiki/references/helpers/network/api.md +986 -0
  79. package/wiki/references/helpers/network/index.md +620 -0
  80. package/wiki/references/helpers/queue/index.md +589 -0
  81. package/wiki/references/helpers/redis/index.md +495 -0
  82. package/wiki/references/helpers/socket-io/api.md +497 -0
  83. package/wiki/references/helpers/socket-io/index.md +513 -0
  84. package/wiki/references/helpers/storage/api.md +705 -0
  85. package/wiki/references/helpers/storage/index.md +583 -0
  86. package/wiki/references/helpers/template/index.md +66 -0
  87. package/wiki/references/helpers/template/single-page.md +126 -0
  88. package/wiki/references/helpers/testing/index.md +510 -0
  89. package/wiki/references/helpers/types/index.md +512 -0
  90. package/wiki/references/helpers/uid/index.md +272 -0
  91. package/wiki/references/helpers/websocket/api.md +736 -0
  92. package/wiki/references/helpers/websocket/index.md +574 -0
  93. package/wiki/references/helpers/worker-thread/index.md +470 -0
  94. package/wiki/references/index.md +2 -9
  95. package/wiki/references/quick-reference.md +3 -18
  96. package/wiki/references/utilities/jsx.md +1 -8
  97. package/wiki/references/utilities/statuses.md +0 -7
  98. package/wiki/references/components/authentication.md +0 -476
  99. package/wiki/references/components/mail.md +0 -687
  100. package/wiki/references/components/socket-io.md +0 -562
  101. package/wiki/references/components/static-asset.md +0 -1277
  102. package/wiki/references/helpers/cron.md +0 -108
  103. package/wiki/references/helpers/crypto.md +0 -132
  104. package/wiki/references/helpers/env.md +0 -83
  105. package/wiki/references/helpers/error.md +0 -97
  106. package/wiki/references/helpers/inversion.md +0 -176
  107. package/wiki/references/helpers/logger.md +0 -296
  108. package/wiki/references/helpers/network.md +0 -396
  109. package/wiki/references/helpers/queue.md +0 -150
  110. package/wiki/references/helpers/redis.md +0 -142
  111. package/wiki/references/helpers/socket-io.md +0 -932
  112. package/wiki/references/helpers/storage.md +0 -665
  113. package/wiki/references/helpers/testing.md +0 -133
  114. package/wiki/references/helpers/types.md +0 -167
  115. package/wiki/references/helpers/uid.md +0 -167
  116. package/wiki/references/helpers/worker-thread.md +0 -178
  117. package/wiki/references/src-details/boot.md +0 -379
  118. package/wiki/references/src-details/core.md +0 -263
  119. package/wiki/references/src-details/dev-configs.md +0 -298
  120. package/wiki/references/src-details/docs.md +0 -71
  121. package/wiki/references/src-details/helpers.md +0 -211
  122. package/wiki/references/src-details/index.md +0 -86
  123. package/wiki/references/src-details/inversion.md +0 -340
@@ -1,379 +0,0 @@
1
- # @venizia/ignis-boot
2
-
3
- > **Package**: `@venizia/ignis-boot`
4
- > **Purpose**: Application bootstrapping system with artifact auto-discovery
5
- > **Version**: 0.0.0
6
-
7
- ## Overview
8
-
9
- The `@venizia/ignis-boot` package provides a powerful bootstrapping system that automatically discovers and loads application artifacts (controllers, services, repositories, datasources) during application startup. It eliminates the need for manual registration of each artifact, making application setup cleaner and more maintainable.
10
-
11
- ## Key Concepts
12
-
13
- ### Boot Phases
14
-
15
- The boot process consists of three phases executed in order:
16
-
17
- 1. **Configure** - Booters configure their discovery patterns
18
- 2. **Discover** - Booters scan filesystem for matching artifacts
19
- 3. **Load** - Booters load classes and bind them to the application container
20
-
21
- ### Artifacts
22
-
23
- An artifact is any application component that can be auto-discovered:
24
- - **Controllers** - REST/API endpoint handlers
25
- - **Services** - Business logic layer
26
- - **Repositories** - Data access layer
27
- - **Datasources** - Database connections
28
-
29
- ### Booters
30
-
31
- Booters are specialized classes that handle discovery and loading of specific artifact types. Each booter:
32
- - Defines default discovery patterns (directories, file extensions)
33
- - Scans filesystem for matching files
34
- - Loads classes from discovered files
35
- - Binds loaded classes to application container
36
-
37
- ## Core Components
38
-
39
- ### Bootstrapper
40
-
41
- Orchestrates the entire boot process.
42
-
43
- | Feature | Description |
44
- |---------|-------------|
45
- | **Phase Execution** | Runs configure → discover → load phases |
46
- | **Booter Discovery** | Automatically finds all registered booters |
47
- | **Error Handling** | Catches and reports errors during boot |
48
- | **Performance Tracking** | Measures time taken for each phase |
49
-
50
- **Usage:**
51
-
52
- ```typescript
53
- import { Bootstrapper, IBootExecutionOptions } from '@venizia/ignis-boot';
54
-
55
- const bootstrapper = app.get<Bootstrapper>({ key: 'bootstrapper' });
56
- await bootstrapper.boot({
57
- phases: ['configure', 'discover', 'load'], // optional, default: all phases
58
- booters: ['ControllerBooter', 'ServiceBooter'], // optional, default: all booters
59
- });
60
- ```
61
-
62
- ### BaseArtifactBooter
63
-
64
- Abstract base class for creating custom booters.
65
-
66
- | Method | Phase | Description |
67
- |--------|-------|-------------|
68
- | `configure()` | Configure | Sets up discovery patterns |
69
- | `discover()` | Discover | Scans filesystem for artifacts |
70
- | `load()` | Load | Loads classes and binds to container |
71
- | `getPattern()` | - | Generates glob pattern for file discovery |
72
- | `bind()` | - | Abstract method - implement to bind loaded classes |
73
-
74
- **Custom Booter Example:**
75
-
76
- ```typescript
77
- import { BaseArtifactBooter, IBooterOptions } from '@venizia/ignis-boot';
78
- import { inject } from '@venizia/ignis-inversion';
79
-
80
- export class CustomBooter extends BaseArtifactBooter {
81
- constructor(
82
- @inject({ key: '@app/project_root' }) root: string,
83
- @inject({ key: '@app/instance' }) private _app: IApplication,
84
- @inject({ key: '@app/boot-options' }) bootOptions: IBootOptions,
85
- ) {
86
- super({
87
- scope: CustomBooter.name,
88
- root,
89
- artifactOptions: bootOptions.custom ?? {}
90
- });
91
- }
92
-
93
- protected getDefaultDirs(): string[] {
94
- return ['custom'];
95
- }
96
-
97
- protected getDefaultExtensions(): string[] {
98
- return ['.custom.js'];
99
- }
100
-
101
- protected async bind(): Promise<void> {
102
- for (const cls of this.loadedClasses) {
103
- this.app.bind({ key: `custom.${cls.name}` }).toClass(cls);
104
- }
105
- }
106
- }
107
- ```
108
-
109
- ### Built-in Booters
110
-
111
- #### ControllerBooter
112
-
113
- Auto-discovers and registers controllers.
114
-
115
- | Configuration | Default Value |
116
- |---------------|---------------|
117
- | **Directories** | `['controllers']` |
118
- | **Extensions** | `['.controller.js']` |
119
- | **Binding Pattern** | `controllers.{ClassName}` |
120
-
121
- #### ServiceBooter
122
-
123
- Auto-discovers and registers services.
124
-
125
- | Configuration | Default Value |
126
- |---------------|---------------|
127
- | **Directories** | `['services']` |
128
- | **Extensions** | `['.service.js']` |
129
- | **Binding Pattern** | `services.{ClassName}` |
130
-
131
- #### RepositoryBooter
132
-
133
- Auto-discovers and registers repositories.
134
-
135
- | Configuration | Default Value |
136
- |---------------|---------------|
137
- | **Directories** | `['repositories']` |
138
- | **Extensions** | `['.repository.js']` |
139
- | **Binding Pattern** | `repositories.{ClassName}` |
140
-
141
- #### DatasourceBooter
142
-
143
- Auto-discovers and registers datasources.
144
-
145
- | Configuration | Default Value |
146
- |---------------|---------------|
147
- | **Directories** | `['datasources']` |
148
- | **Extensions** | `['.datasource.js']` |
149
- | **Binding Pattern** | `datasources.{ClassName}` |
150
-
151
- ### BootMixin
152
-
153
- Mixin that adds bootable capability to any application.
154
-
155
- **Features:**
156
- - Automatically binds default booters
157
- - Exposes `boot()` method
158
- - Configurable via `bootOptions`
159
-
160
- **Usage:**
161
-
162
- ```typescript
163
- import { BootMixin } from '@venizia/ignis-boot';
164
- import { Container } from '@venizia/ignis-inversion';
165
-
166
- class MyApp extends BootMixin(Container) {
167
- bootOptions = {
168
- controllers: {
169
- dirs: ['private-controllers', 'public-controllers'],
170
- extensions: ['.controller.js', '.controller.ts']
171
- },
172
- services: {
173
- isNested: true // scan subdirectories
174
- }
175
- };
176
- }
177
-
178
- const app = new MyApp();
179
- await app.boot();
180
- ```
181
-
182
- ## Boot Options
183
-
184
- Configure artifact discovery per artifact type.
185
-
186
- ### IArtifactOptions
187
-
188
- | Property | Type | Default | Description |
189
- |----------|------|---------|-------------|
190
- | `dirs` | `string[]` | Varies | Directories to scan |
191
- | `extensions` | `string[]` | Varies | File extensions to match |
192
- | `isNested` | `boolean` | `true` | Scan subdirectories |
193
- | `glob` | `string` | - | Custom glob pattern (overrides dirs/extensions) |
194
-
195
- ### IBootOptions
196
-
197
- ```typescript
198
- interface IBootOptions {
199
- controllers?: IArtifactOptions;
200
- services?: IArtifactOptions;
201
- repositories?: IArtifactOptions;
202
- datasources?: IArtifactOptions;
203
- [artifactType: string]: IArtifactOptions | undefined;
204
- }
205
- ```
206
-
207
- **Example Configuration:**
208
-
209
- ```typescript
210
- const bootOptions: IBootOptions = {
211
- controllers: {
212
- dirs: ['controllers/private', 'controllers/public'],
213
- extensions: ['.controller.js'],
214
- isNested: true
215
- },
216
- repositories: {
217
- glob: 'data-access/**/*.repository.js' // custom pattern
218
- },
219
- services: {
220
- dirs: ['services'],
221
- extensions: ['.service.js', '.service.ts'],
222
- isNested: false // only scan root level
223
- }
224
- };
225
- ```
226
-
227
- ## Integration with Core
228
-
229
- ### BaseApplication Integration
230
-
231
- Boot system is integrated into `BaseApplication` via `IBootableApplication` interface:
232
-
233
- ```typescript
234
- export abstract class BaseApplication
235
- extends AbstractApplication
236
- implements IRestApplication, IBootableApplication {
237
-
238
- bootOptions?: IBootOptions;
239
-
240
- boot(): Promise<IBootReport> {
241
- const bootstrapper = this.get<Bootstrapper>({ key: 'bootstrapper' });
242
- return bootstrapper.boot({});
243
- }
244
- }
245
- ```
246
-
247
- ### Automatic Initialization
248
-
249
- If `bootOptions` is defined in application config, boot runs automatically during `initialize()`:
250
-
251
- ```typescript
252
- override async initialize() {
253
- if (this.configs.bootOptions) {
254
- // Bind boot infrastructure
255
- this.bind({ key: '@app/boot-options' }).toValue(this.bootOptions ?? {});
256
- this.bind({ key: 'bootstrapper' }).toClass(Bootstrapper);
257
-
258
- // Register default booters
259
- this.booter(DatasourceBooter);
260
- this.booter(RepositoryBooter);
261
- this.booter(ServiceBooter);
262
- this.booter(ControllerBooter);
263
-
264
- // Execute boot
265
- await this.boot();
266
- }
267
-
268
- // ... rest of initialization
269
- }
270
- ```
271
-
272
- ## Utilities
273
-
274
- ### discoverFiles
275
-
276
- Discovers files matching a glob pattern.
277
-
278
- ```typescript
279
- const files = await discoverFiles({
280
- pattern: 'controllers/**/*.controller.js',
281
- root: '/path/to/project'
282
- });
283
- // Returns: ['/path/to/project/controllers/user.controller.js', ...]
284
- ```
285
-
286
- ### loadClasses
287
-
288
- Loads class constructors from files.
289
-
290
- ```typescript
291
- const classes = await loadClasses({
292
- files: ['/path/to/file1.js', '/path/to/file2.js'],
293
- root: '/path/to/project'
294
- });
295
- // Returns: [UserController, ProductController, ...]
296
- ```
297
-
298
- ### isClass
299
-
300
- Type guard to check if value is a class constructor.
301
-
302
- ```typescript
303
- if (isClass(exported)) {
304
- // exported is TClass<any>
305
- }
306
- ```
307
-
308
- ## Complete Example
309
-
310
- ```typescript
311
- import { BaseApplication, IApplicationConfigs } from '@venizia/ignis';
312
- import { IBootOptions } from '@venizia/ignis-boot';
313
-
314
- export const appConfigs: IApplicationConfigs = {
315
- name: 'MyApp',
316
- bootOptions: {
317
- controllers: {
318
- dirs: ['controllers'],
319
- extensions: ['.controller.js'],
320
- isNested: true
321
- },
322
- services: {
323
- dirs: ['services'],
324
- extensions: ['.service.js'],
325
- isNested: true
326
- },
327
- repositories: {
328
- dirs: ['repositories'],
329
- extensions: ['.repository.js']
330
- },
331
- datasources: {
332
- dirs: ['datasources'],
333
- extensions: ['.datasource.js']
334
- }
335
- }
336
- };
337
-
338
- export class MyApp extends BaseApplication {
339
- constructor() {
340
- super(appConfigs);
341
- }
342
- }
343
-
344
- // Boot runs automatically during initialize()
345
- const app = new MyApp();
346
- await app.start(); // Calls initialize() which triggers boot
347
- ```
348
-
349
- ## Benefits
350
-
351
- | Benefit | Description |
352
- |---------|-------------|
353
- | **Auto-discovery** | No manual registration of controllers/services/repositories |
354
- | **Convention-based** | Follow naming conventions, framework handles the rest |
355
- | **Flexible** | Customize discovery patterns per artifact type |
356
- | **Extensible** | Create custom booters for new artifact types |
357
- | **Performance** | Track boot time per phase |
358
- | **Developer Experience** | Focus on writing code, not wiring infrastructure |
359
-
360
- ## When to Use
361
-
362
- ✅ **Use Boot System When:**
363
- - Building applications with many controllers/services/repositories
364
- - Want convention-over-configuration approach
365
- - Need consistent artifact registration across projects
366
- - Building modular applications with clear folder structure
367
-
368
- ❌ **Manual Registration When:**
369
- - Very small applications (< 5 artifacts)
370
- - Need fine-grained control over registration order
371
- - Dynamic artifact registration based on runtime conditions
372
- - Artifacts don't follow file naming conventions
373
-
374
- ## Related Documentation
375
-
376
- - [Bootstrapping Concepts](/guides/core-concepts/application/bootstrapping)
377
- - [Application Guide](/guides/core-concepts/application/)
378
- - [Dependency Injection](/references/base/dependency-injection.md)
379
- - [Core Package](/references/src-details/core.md)
@@ -1,263 +0,0 @@
1
- # Package: `@venizia/ignis`
2
-
3
- Detailed breakdown of the core framework directory structure.
4
-
5
- ## Quick Reference
6
-
7
- **Package:** Core framework with fundamental building blocks, architectural layers, and modular features.
8
-
9
- ### Top-Level Directories
10
-
11
- | Directory | Primary Focus | Key Components |
12
- |-----------|---------------|----------------|
13
- | **`base`** | Core architecture | Applications, Controllers, Repositories, Services, Models |
14
- | **`components`** | Pluggable features | Auth, Swagger, HealthCheck, SocketIO |
15
- | **`helpers`** | Utilities | DI (extended), Re-exports from `@venizia/ignis-helpers` |
16
- | **`common`** | Shared code | Constants, bindings, types, environments |
17
- | **`utilities`** | Pure functions | Crypto, date, parse, performance, schema |
18
- | **`__tests__`** | Tests | Integration and E2E tests |
19
-
20
- ## Project Structure Overview
21
-
22
- Top-level breakdown of the `src` directory:
23
-
24
- | Folder | Purpose |
25
- | :--------------- | :--------------------------------------------------------------------------------------------------------------------- |
26
- | **`__tests__`** | Contains integration and end-to-end tests for the framework's features. |
27
- | **`base`** | The core building blocks and abstract classes of the framework. This is where the fundamental architecture is defined. |
28
- | **`common`** | A directory for code that is shared and used across the entire framework. |
29
- | **`components`** | A collection of ready-to-use, high-level components that can be plugged into an Ignis application. |
30
- | **`helpers`** | Contains core extensions (like Inversion) and re-exports from `@venizia/ignis-helpers`. |
31
- | **`utilities`** | A collection of pure, standalone utility functions. |
32
-
33
- ---
34
-
35
- ## Detailed Sections
36
-
37
- ### `__tests__`
38
-
39
- This directory is dedicated to the framework's test suite.
40
-
41
- | File/Folder | Purpose/Key Details |
42
- | :---------------------- | :------------------------------------------------------------------------------------------------------------------------------- |
43
- | `jwt/` | Contains test cases specifically for the JWT authentication functionality, demonstrating how tokens are generated and validated. |
44
- | `jwt/test-cases/jwt.ts` | Example: defines `TestCase001` to check JWT creation. |
45
-
46
- ### `base`
47
-
48
- This is the foundational layer of Ignis, defining the core architecture and abstract classes that other parts of the framework extend or implement.
49
-
50
- #### `base/applications`
51
-
52
- | File/Folder | Purpose/Key Details |
53
- | :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
- | `abstract.ts` | Defines `AbstractApplication`, the base class for Ignis applications. Handles core server setup (Hono instance, runtime detection for Bun/Node.js), environment validation, and route inspection. Mandates abstract methods for middleware setup and configuration. |
55
- | `base.ts` | Extends `AbstractApplication` to provide `BaseApplication`, implementing common functionalities like component, controller, service, repository, and datasource registration. Includes default middleware registration (e.g., error handling, favicon, request tracking) and startup information logging. Integrates with `@venizia/ignis-boot` for automatic artifact discovery when `bootOptions` is configured. |
56
- | `types.ts` | Contains interfaces for application configurations (`IApplicationConfigs`), application information (`IApplicationInfo`), and various middleware options (e.g., `ICORSOptions`, `ICSRFOptions`). Now includes `IBootableApplication` interface for boot system integration. |
57
-
58
- #### `base/components`
59
-
60
- | File/Folder | Purpose/Key Details |
61
- | :---------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
- | `base.ts` | Defines `BaseComponent`, the abstract class for all pluggable components. Manages component-specific bindings and a `configure()` method for setup logic. |
63
-
64
- #### `base/controllers`
65
-
66
- | File/Folder | Purpose/Key Details |
67
- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68
- | `abstract.ts` | Defines `AbstractController`, an abstract class providing core controller functionalities like `getRouteConfigs` for standardizing route configurations, and `registerRoutesFromRegistry()` for automatically registering decorator-based routes. |
69
- | `base.ts` | Extends `AbstractController` to provide `BaseController`, an abstract class for handling HTTP requests. Integrates with `@hono/zod-openapi` for route definition and OpenAPI schema generation. Key methods include `defineRoute` and `bindRoute`. |
70
- | `factory/` | Contains the `ControllerFactory` and related helpers for generating controllers. |
71
- | `factory/controller.ts` | Provides `ControllerFactory` to generate pre-configured CRUD controllers from a given entity and repository. |
72
- | `factory/definition.ts` | Exports route definition helpers. |
73
- | `common/` | Contains shared types (`types.ts`) and constants (`constants.ts`) for the controller layer. |
74
-
75
- #### `base/datasources`
76
-
77
- | File/Folder | Purpose/Key Details |
78
- | :---------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
79
- | `base.ts` | Contains `AbstractDataSource` and `BaseDataSource`, abstract classes for managing database connections. They define methods for configuration (`configure()`) and retrieving connection strings. |
80
- | `types.ts` | Defines `IDataSource` interface and `TDataSourceDriver` (e.g., `node-postgres`). |
81
-
82
- #### `base/helpers`
83
-
84
- | File/Folder | Purpose/Key Details |
85
- | :---------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
86
- | `base.ts` | `BaseHelper` is a generic base class providing common utilities like a logger instance and scope management. Many other helpers and components extend this class. |
87
-
88
- #### `base/metadata`
89
-
90
- This directory centralizes the metadata handling for decorators, crucial for Ignis's DI and routing systems.
91
-
92
- | File/Folder | Purpose/Key Details |
93
- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
94
- | `injectors.ts` | Defines the `@injectable` and `@inject` decorators for dependency injection. |
95
- | `persistents.ts` | Contains `@model` and `@datasource` decorators for marking classes as data models or data sources, respectively. |
96
- | `routes.ts` | Defines the `@controller` decorator for marking classes as API controllers, and the new decorator set (`@api`, `@get`, `@post`, etc.) for defining routes on controller methods. |
97
-
98
- #### `base/middlewares`
99
-
100
- A collection of essential, low-level middlewares used by the application.
101
-
102
- | File/Folder | Purpose/Key Details |
103
- | :-------------------------------- | :------------------------------------------------------------------------------------------------------------- |
104
- | `app-error.middleware.ts` | Global error handling middleware that catches `ApplicationError` instances and formats responses consistently. |
105
- | `emoji-favicon.middleware.ts` | Serves a simple emoji favicon for the application. |
106
- | `not-found.middleware.ts` | Handles 404 Not Found errors. |
107
- | `request-spy.middleware.ts` | Logs incoming requests, parses request body, and adds a unique request ID for tracing. |
108
-
109
- #### `base/mixins`
110
-
111
- Contains mixins to extend the functionality of core classes, particularly `AbstractApplication`.
112
-
113
- | File/Folder | Purpose/Key Details |
114
- | :-------------------- | :------------------------------------------------------- |
115
- | `component.mixin.ts` | Adds `component()` and `registerComponents()` methods. |
116
- | `controller.mixin.ts` | Adds `controller()` and `registerControllers()` methods. |
117
- | `repository.mixin.ts` | Adds `dataSource()` and `repository()` methods. |
118
- | `service.mixin.ts` | Adds `service()` method. |
119
- | `types.ts` | Defines interfaces and types (`TMixinOpts`, `IComponentMixin`, `IControllerMixin`, etc.). |
120
-
121
- All registration methods accept an optional `opts?: TMixinOpts` parameter for custom binding configuration:
122
-
123
- ```typescript
124
- type TMixinOpts<Args extends AnyObject = any> = {
125
- binding: { namespace: string; key: string };
126
- args?: Args;
127
- };
128
-
129
- // Example: Custom binding key
130
- this.controller(UserController, {
131
- binding: { namespace: 'controllers', key: 'CustomUserController' }
132
- });
133
- ```
134
-
135
- #### `base/models`
136
-
137
- Defines base classes and utilities for data models, often used with Drizzle ORM.
138
-
139
- | File/Folder | Purpose/Key Details |
140
- | :--------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
141
- | `base.ts` | Contains `BaseEntity`, a base class for models that wrap Drizzle ORM schemas and provide methods for generating Zod schemas for CRUD operations. |
142
- | `common/` | Contains shared types (`types.ts`) and constants (`constants.ts`) for the model layer, including definitions for `IdType`, `TTableSchemaWithId`, and `SchemaTypes`. |
143
- | `enrichers/` | Sub-directory for functions that add common fields to Drizzle ORM schemas. |
144
- | `enrichers/data-type.enricher.ts` | Adds generic data type columns (number, text, byte, JSON, boolean). |
145
- | `enrichers/id.enricher.ts` | Adds `id` column with number (serial) or string (UUID) types. |
146
- | `enrichers/principal.enricher.ts` | Adds polymorphic fields for associating with different principal types. |
147
- | `enrichers/tz.enricher.ts` | Adds `createdAt` and `modifiedAt` timestamp columns. |
148
- | `enrichers/user-audit.enricher.ts` | Adds `createdBy` and `modifiedBy` fields. Supports `allowAnonymous` option to require or allow anonymous user context. |
149
-
150
- #### `base/providers`
151
-
152
- | File/Folder | Purpose/Key Details |
153
- | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
154
- | `base.ts` | Contains `BaseProvider`, an abstract class for creating custom dependency injection providers. Providers are used for dependencies that require complex instantiation logic. |
155
-
156
- #### `base/repositories`
157
-
158
- | File/Folder | Purpose/Key Details |
159
- | :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- |
160
- | `core/base.ts` | Defines `AbstractRepository`, the abstract base class for all repositories. |
161
- | `core/readable.ts` | Implements `ReadableRepository` for **read-only** data access. |
162
- | `core/persistable.ts` | Implements `PersistableRepository`, extending `ReadableRepository` with write capabilities (`create`, `update`, `delete`). |
163
- | `core/default-crud.ts` | Provides `DefaultCRUDRepository`, the standard full CRUD repository that extends `PersistableRepository`. |
164
- | `common/types.ts` | Defines interfaces for filters (`TFilter`), WHERE clauses (`TWhere`), and repository operations (`IRepository`, `IPersistableRepository`). |
165
-
166
- #### `base/services`
167
-
168
- | File/Folder | Purpose/Key Details |
169
- | :---------- | :------------------------------------------------------------------------ |
170
- | `base.ts` | Defines `BaseService`, the abstract base for all business logic services. |
171
- | `types.ts` | Defines `IService` and `ICrudService` interfaces. |
172
-
173
- ### `common`
174
-
175
- This directory holds various shared definitions and constants used throughout the framework.
176
-
177
- | File/Folder | Purpose/Key Details |
178
- | :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
179
- | `bindings.ts` | Defines `BindingNamespaces` (e.g., `COMPONENT`, `SERVICE`) and `BindingKeys` (`APPLICATION_INSTANCE`, `APPLICATION_SERVER`) for the dependency injection container. |
180
- | `constants.ts` | Contains application-wide constants such as `HTTP` methods and status codes, `MimeTypes`, `RuntimeModules` (Bun, Node.js), and `DataTypes`. |
181
- | `environments.ts` | Defines `Environment` types (e.g., `DEVELOPMENT`, `PRODUCTION`) and `EnvironmentKeys` for structured access to environment variables. |
182
- | `statuses.ts` | Defines various status constants like `UserStatuses`, `RoleStatuses`, and `MigrationStatuses`. |
183
- | `types.ts` | Contains general TypeScript utility types like `ValueOrPromise`, `AnyObject`, `IClass`, `TMixinTarget`, and `IProvider`. |
184
-
185
- ### `components`
186
-
187
- This directory contains high-level, pluggable components that encapsulate specific features, extending the application's functionality.
188
-
189
- #### `components/auth/`
190
-
191
- Provides authentication and authorization features.
192
-
193
- | File/Folder | Purpose/Key Details |
194
- | :--------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
195
- | `authenticate/` | JWT-based authentication. |
196
- | `authenticate/common/` | Constants, keys, and types for authentication. |
197
- | `authenticate/component.ts` | `AuthenticateComponent` registers authentication services and controllers. |
198
- | `authenticate/controllers/factory.ts` | `defineAuthController` creates a pre-configured controller with sign-in, sign-up, change password, and "who am I" routes. |
199
- | `authenticate/services/jwt-token.service.ts` | `JWTTokenService` handles JWT generation, verification, and payload encryption/decryption. |
200
- | `authenticate/strategies/` | Authentication strategies, e.g., `JWTAuthenticationStrategy`. |
201
- | `authenticate/strategies/strategy-registry.ts` | `AuthenticationStrategyRegistry` manages and provides authentication strategies. |
202
- | `models/` | Data models (entities and requests) for authentication, including `User`, `Role`, `Permission`, `SignInRequestSchema`, `SignUpRequestSchema`, etc. |
203
-
204
- #### `components/health-check/`
205
-
206
- Adds a simple `/health` endpoint to the application.
207
-
208
- | File/Folder | Purpose/Key Details |
209
- | :-------------- | :------------------------------------------------------------ |
210
- | `component.ts` | `HealthCheckComponent` registers the `HealthCheckController`. |
211
- | `controller.ts` | `HealthCheckController` defines the `/health` route. |
212
-
213
- #### `components/request-tracker/`
214
-
215
- Logs and traces incoming requests.
216
-
217
- | File/Folder | Purpose/Key Details |
218
- | :------------- | :------------------------------------------------------------------------------------------------------ |
219
- | `component.ts` | `RequestTrackerComponent` integrates `hono/request-id` and `RequestSpyMiddleware` for request tracking. |
220
-
221
- #### `components/socket-io/`
222
-
223
- Integrates Socket.IO for real-time communication.
224
-
225
- | File/Folder | Purpose/Key Details |
226
- | :------------- | :--------------------------------------------------------------------------------------------------------------- |
227
- | `component.ts` | `SocketIOComponent` sets up the Socket.IO server, integrates with Redis for scaling, and handles authentication. |
228
-
229
- #### `components/swagger/`
230
-
231
- Generates interactive OpenAPI documentation.
232
-
233
- | File/Folder | Purpose/Key Details |
234
- | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------- |
235
- | `component.ts` | `SwaggerComponent` configures Swagger UI using `@hono/zod-openapi` and `@hono/swagger-ui`, generating documentation from route schemas. |
236
-
237
- ### `helpers`
238
-
239
- Contains framework extensions and utilities.
240
-
241
- | File/Folder | Purpose/Key Details |
242
- | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
243
- | `inversion/`| **Framework DI Extension**: Extends `@venizia/ignis-inversion` to provide application-aware dependency injection with logging and enhanced metadata support. |
244
- | `index.ts` | Re-exports extensions and utilities from `@venizia/ignis-helpers`. |
245
-
246
- ### `utilities`
247
-
248
- This directory contains pure, standalone utility functions that perform common, stateless operations.
249
-
250
- | File/Folder | Purpose/Key Details |
251
- | :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
252
- | `crypto.utility.ts` | Provides a `hash()` function for cryptographic hashing (SHA256, MD5). |
253
- | `date.utility.ts` | Date and time manipulation functions (`dayjs` integration, `sleep`, `isWeekday`, `getDateTz`, `hrTime`). |
254
- | `module.utility.ts` | `validateModule()` to check for module existence at runtime. |
255
- | `parse.utility.ts` | Functions for type checking (`isInt`, `isFloat`), type conversion (`int`, `float`, `toBoolean`), string/object transformation (`toCamel`, `keysToCamel`), array transformations (`parseArrayToRecordWithKey`, `parseArrayToMapWithKey`), and `getUID()` for unique IDs. |
256
- | `performance.utility.ts` | Utilities for measuring code execution time (`executeWithPerformanceMeasure`, `getPerformanceCheckpoint`, `getExecutedPerformance`). |
257
- | `promise.utility.ts` | Helper functions for Promises (`executePromiseWithLimit`, `isPromiseLike`, `transformValueOrPromise`, `getDeepProperty`). |
258
- | `request.utility.ts` | Utilities for handling HTTP request data, such as `parseMultipartBody` for multipart form data. |
259
- | `schema.utility.ts` | Helper functions and predefined schemas for `zod` and `@hono/zod-openapi` (`jsonContent`, `jsonResponse`, `requiredString`, `AnyObjectSchema`, `IdParamsSchema`, `UUIDParamsSchema`). |
260
-
261
- ---
262
-
263
- This detailed breakdown illustrates the modular and layered design of the Ignis framework, emphasizing its extensibility and adherence to robust architectural patterns.