@venizia/ignis-docs 0.0.1-8 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE.md +1 -0
  2. package/package.json +2 -2
  3. package/wiki/changelogs/2025-12-16-initial-architecture.md +145 -0
  4. package/wiki/changelogs/2025-12-16-model-repo-datasource-refactor.md +300 -0
  5. package/wiki/changelogs/2025-12-17-refactor.md +90 -0
  6. package/wiki/changelogs/2025-12-18-performance-optimizations.md +130 -0
  7. package/wiki/changelogs/2025-12-18-repository-validation-security.md +249 -0
  8. package/wiki/changelogs/index.md +33 -0
  9. package/wiki/changelogs/planned-transaction-support.md +216 -0
  10. package/wiki/changelogs/template.md +123 -0
  11. package/wiki/get-started/5-minute-quickstart.md +1 -1
  12. package/wiki/get-started/best-practices/api-usage-examples.md +12 -10
  13. package/wiki/get-started/best-practices/architectural-patterns.md +2 -2
  14. package/wiki/get-started/best-practices/common-pitfalls.md +7 -5
  15. package/wiki/get-started/best-practices/contribution-workflow.md +2 -0
  16. package/wiki/get-started/best-practices/data-modeling.md +91 -40
  17. package/wiki/get-started/best-practices/security-guidelines.md +3 -1
  18. package/wiki/get-started/building-a-crud-api.md +63 -78
  19. package/wiki/get-started/core-concepts/application.md +72 -3
  20. package/wiki/get-started/core-concepts/bootstrapping.md +566 -0
  21. package/wiki/get-started/core-concepts/components.md +4 -2
  22. package/wiki/get-started/core-concepts/controllers.md +14 -14
  23. package/wiki/get-started/core-concepts/persistent.md +383 -431
  24. package/wiki/get-started/core-concepts/services.md +21 -27
  25. package/wiki/get-started/quickstart.md +1 -1
  26. package/wiki/references/base/bootstrapping.md +789 -0
  27. package/wiki/references/base/components.md +1 -1
  28. package/wiki/references/base/controllers.md +40 -16
  29. package/wiki/references/base/datasources.md +195 -33
  30. package/wiki/references/base/dependency-injection.md +98 -5
  31. package/wiki/references/base/models.md +398 -28
  32. package/wiki/references/base/repositories.md +475 -22
  33. package/wiki/references/base/services.md +2 -2
  34. package/wiki/references/components/authentication.md +228 -10
  35. package/wiki/references/components/health-check.md +1 -1
  36. package/wiki/references/components/index.md +1 -1
  37. package/wiki/references/components/swagger.md +1 -1
  38. package/wiki/references/helpers/error.md +2 -2
  39. package/wiki/references/helpers/inversion.md +8 -3
  40. package/wiki/references/src-details/boot.md +379 -0
  41. package/wiki/references/src-details/core.md +8 -7
  42. package/wiki/references/src-details/inversion.md +4 -4
  43. package/wiki/references/utilities/request.md +16 -7
@@ -9,7 +9,8 @@ Services contain your application's business logic, orchestrating data flow and
9
9
  Services contain the core business logic of your application. They orchestrate the flow of data and execute the application's use cases. A service's primary responsibilities are:
10
10
 
11
11
  - **Encapsulating Business Rules**: Centralizing logic such as calculations, data validation, and process workflows.
12
- - **Coordinating Data Operations**: Using one or more repositories to fetch and persist data.
12
+ - **Coordinating Operations**: Using repositories to fetch and persist data, or orchestrating other services to execute complex business workflows.
13
+ - **Reusing Business Logic**: Services can inject other services to reuse established logic, ensuring "Don't Repeat Yourself" (DRY) principles are maintained across the application.
13
14
  - **Isolating Controllers**: Keeping controllers thin by handling all the complex logic, so controllers are only responsible for handling the HTTP request and response.
14
15
 
15
16
  ### Creating a Service
@@ -17,9 +18,10 @@ Services contain the core business logic of your application. They orchestrate t
17
18
  To create a service, you extend the `BaseService` class and inject the repositories or other services it depends on.
18
19
 
19
20
  ```typescript
20
- import { BaseService, inject } from '@venizia/ignis';
21
+ import { BaseService, inject, getError } from '@venizia/ignis';
21
22
  import { ConfigurationRepository } from '../repositories';
22
23
  import { UserRepository } from '../repositories';
24
+ import { LoggingService } from './logging.service'; // Example of another service
23
25
  import { TConfiguration } from '../models/entities';
24
26
 
25
27
  export class ConfigurationService extends BaseService {
@@ -28,53 +30,45 @@ export class ConfigurationService extends BaseService {
28
30
  private configurationRepository: ConfigurationRepository,
29
31
  @inject({ key: 'repositories.UserRepository' })
30
32
  private userRepository: UserRepository,
33
+ @inject({ key: 'services.LoggingService' })
34
+ private loggingService: LoggingService, // Injecting another service for reuse
31
35
  ) {
32
36
  super({ scope: ConfigurationService.name });
33
37
  }
34
38
 
35
39
  async createConfigurationForUser(userId: string, data: Partial<TConfiguration>): Promise<TConfiguration> {
40
+ // Call another service logic
41
+ await this.loggingService.audit(`Creating config for user: ${userId}`);
42
+
36
43
  // Business logic: Check if the user exists
37
44
  const user = await this.userRepository.findById({ id: userId });
38
- if (!user) {
39
- throw new Error(`User with ID ${userId} not found.`);
40
- }
41
-
42
- // Business logic: Check for duplicate configuration code
43
- const existingConfig = await this.configurationRepository.findOne({ where: { code: data.code } });
44
- if (existingConfig) {
45
- throw new Error('Configuration with this code already exists.');
46
- }
47
-
48
- // Use the repository to create the configuration, assigning the creator
49
- const newConfigData = { ...data, createdBy: userId, modifiedBy: userId };
50
- return this.configurationRepository.create(newConfigData);
51
- }
52
- }
45
+ // ...
53
46
  ```
54
47
 
55
48
  ## How Services Fit into the Architecture
56
49
 
57
- Services act as the intermediary between controllers and repositories, ensuring a clean separation of concerns.
50
+ Services act as the primary layer for business logic, sitting between controllers and repositories. While controllers are the typical entry point, **services can also inject and call other services**. This enables powerful logic reuse and allows you to build complex use cases by composing smaller, specialized services.
58
51
 
59
52
  ```mermaid
60
53
  graph LR
61
54
  A[Client Request] --> B(Controller);
62
- B --> C{Service};
63
- C --> D[Repository];
64
- D --> E((Database));
65
- E --> D;
66
- D --> C;
67
- C --> B;
68
- B --> F[Client Response];
55
+ B --> C1{Service A};
56
+ C1 --> C2{Service B};
57
+ C1 --> D1[Repository A];
58
+ C2 --> D2[Repository B];
59
+ D1 --> E((Database));
60
+ D2 --> E;
69
61
 
70
62
  subgraph "Presentation Layer"
71
63
  B
72
64
  end
73
65
  subgraph "Business Logic Layer"
74
- C
66
+ C1
67
+ C2
75
68
  end
76
69
  subgraph "Data Access Layer"
77
- D
70
+ D1
71
+ D2
78
72
  end
79
73
  subgraph "Data Store"
80
74
  E
@@ -265,7 +265,7 @@ export class HelloController extends BaseController {
265
265
  })
266
266
  sayHello(c: Context) {
267
267
  // This looks just like Hono! Because it IS Hono under the hood.
268
- return c.json({ message: 'Hello, World!' });
268
+ return c.json({ message: 'Hello, World!' }, HTTP.ResultCodes.RS_2.Ok);
269
269
  }
270
270
 
271
271
  // You can add more routes here: