@venizia/ignis-docs 0.2.0 → 0.2.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/content/best-practices/api-usage-examples.md +39 -19
- package/content/best-practices/architectural-patterns.md +24 -13
- package/content/best-practices/architecture-decisions.md +29 -16
- package/content/best-practices/code-style-standards/advanced-patterns.md +43 -31
- package/content/best-practices/code-style-standards/constants-configuration.md +19 -4
- package/content/best-practices/code-style-standards/control-flow.md +33 -1
- package/content/best-practices/code-style-standards/documentation.md +28 -8
- package/content/best-practices/code-style-standards/function-patterns.md +15 -4
- package/content/best-practices/code-style-standards/index.md +7 -2
- package/content/best-practices/code-style-standards/naming-conventions.md +27 -3
- package/content/best-practices/code-style-standards/route-definitions.md +9 -5
- package/content/best-practices/code-style-standards/tooling.md +14 -1
- package/content/best-practices/code-style-standards/type-safety.md +39 -6
- package/content/best-practices/common-pitfalls.md +59 -35
- package/content/best-practices/contribution-workflow.md +8 -4
- package/content/best-practices/data-modeling.md +78 -62
- package/content/best-practices/deployment-strategies.md +56 -19
- package/content/best-practices/error-handling.md +247 -153
- package/content/best-practices/index.md +6 -0
- package/content/best-practices/performance-optimization.md +26 -13
- package/content/best-practices/security-guidelines.md +35 -9
- package/content/best-practices/testing-strategies.md +7 -2
- package/content/best-practices/troubleshooting-tips.md +27 -17
- package/content/extensions/components/api-reference.md +109 -323
- package/content/extensions/components/authentication/api.md +489 -602
- package/content/extensions/components/authentication/errors.md +135 -498
- package/content/extensions/components/authentication/index.md +89 -801
- package/content/extensions/components/authentication/usage.md +231 -955
- package/content/extensions/components/authorization/api.md +991 -644
- package/content/extensions/components/authorization/errors.md +204 -208
- package/content/extensions/components/authorization/getting-started.md +227 -0
- package/content/extensions/components/authorization/index.md +88 -795
- package/content/extensions/components/authorization/usage.md +219 -528
- package/content/extensions/components/health-check.md +77 -243
- package/content/extensions/components/index.md +24 -90
- package/content/extensions/components/mail/api.md +553 -285
- package/content/extensions/components/mail/errors.md +76 -62
- package/content/extensions/components/mail/index.md +111 -463
- package/content/extensions/components/mail/usage.md +139 -173
- package/content/extensions/components/request-tracker.md +70 -173
- package/content/extensions/components/socket-io/api.md +462 -785
- package/content/extensions/components/socket-io/errors.md +49 -51
- package/content/extensions/components/socket-io/index.md +69 -372
- package/content/extensions/components/socket-io/usage.md +212 -105
- package/content/extensions/components/static-asset/api.md +461 -141
- package/content/extensions/components/static-asset/errors.md +121 -53
- package/content/extensions/components/static-asset/index.md +84 -606
- package/content/extensions/components/static-asset/usage.md +184 -299
- package/content/extensions/components/template/index.md +3 -3
- package/content/extensions/components/websocket/api.md +311 -404
- package/content/extensions/components/websocket/errors.md +47 -56
- package/content/extensions/components/websocket/index.md +75 -407
- package/content/extensions/components/websocket/usage.md +120 -338
- package/content/extensions/helpers/cron/index.md +52 -160
- package/content/extensions/helpers/crypto/index.md +67 -480
- package/content/extensions/helpers/crypto/reference.md +528 -0
- package/content/extensions/helpers/env/index.md +64 -178
- package/content/extensions/helpers/error/index.md +286 -196
- package/content/extensions/helpers/index.md +61 -47
- package/content/extensions/helpers/inversion/index.md +76 -550
- package/content/extensions/helpers/inversion/reference.md +530 -0
- package/content/extensions/helpers/kafka/admin.md +23 -3
- package/content/extensions/helpers/kafka/compile-binary.md +83 -52
- package/content/extensions/helpers/kafka/consumer.md +65 -28
- package/content/extensions/helpers/kafka/examples.md +46 -253
- package/content/extensions/helpers/kafka/index.md +55 -617
- package/content/extensions/helpers/kafka/producer.md +156 -22
- package/content/extensions/helpers/kafka/schema-registry.md +59 -79
- package/content/extensions/helpers/logger/hf-logger.md +220 -0
- package/content/extensions/helpers/logger/index.md +78 -552
- package/content/extensions/helpers/logger/pino.md +105 -0
- package/content/extensions/helpers/logger/reference.md +937 -0
- package/content/extensions/helpers/network/api.md +276 -195
- package/content/extensions/helpers/network/index.md +87 -524
- package/content/extensions/helpers/queue/index.md +80 -897
- package/content/extensions/helpers/queue/reference.md +494 -0
- package/content/extensions/helpers/redis/index.md +86 -640
- package/content/extensions/helpers/redis/reference.md +784 -0
- package/content/extensions/helpers/secrets/index.md +136 -0
- package/content/extensions/helpers/socket-io/api.md +325 -204
- package/content/extensions/helpers/socket-io/index.md +79 -429
- package/content/extensions/helpers/storage/api.md +584 -464
- package/content/extensions/helpers/storage/index.md +80 -573
- package/content/extensions/helpers/types/index.md +75 -495
- package/content/extensions/helpers/types/reference.md +689 -0
- package/content/extensions/helpers/uid/index.md +176 -189
- package/content/extensions/helpers/websocket/api.md +366 -214
- package/content/extensions/helpers/websocket/index.md +68 -503
- package/content/extensions/helpers/worker-thread/index.md +62 -396
- package/content/extensions/helpers/worker-thread/reference.md +428 -0
- package/content/extensions/index.md +38 -39
- package/content/extensions/src-details/mcp-server.md +96 -548
- package/content/guides/core-concepts/persistent/datasources.md +2 -2
- package/content/guides/core-concepts/persistent/index.md +5 -1
- package/content/guides/core-concepts/persistent/models.md +1 -1
- package/content/guides/core-concepts/persistent/pglite.md +218 -0
- package/content/guides/core-concepts/persistent/postgres-drivers.md +21 -15
- package/content/guides/core-concepts/persistent/search-meilisearch.md +22 -12
- package/content/guides/core-concepts/persistent/search-typesense.md +28 -16
- package/content/guides/core-concepts/persistent/sqlite.md +296 -0
- package/content/guides/core-concepts/persistent/transactions.md +12 -11
- package/content/guides/core-concepts/secrets-vault.md +177 -0
- package/content/guides/core-concepts/services.md +1 -1
- package/content/guides/get-started/5-minute-quickstart.md +59 -206
- package/content/guides/get-started/philosophy.md +135 -670
- package/content/guides/get-started/setup.md +53 -74
- package/content/guides/migrations/redis-helpers-migration.md +5 -4
- package/content/guides/migrations/scoped-rbac-migration.md +5 -5
- package/content/guides/migrations/unified-connectors-migration.md +8 -7
- package/content/guides/tutorials/ecommerce-api.md +3 -8
- package/content/guides/tutorials/realtime-chat.md +1 -1
- package/content/references/base/application.md +64 -22
- package/content/references/base/components.md +3 -3
- package/content/references/base/connectors.md +79 -136
- package/content/references/base/controllers.md +12 -12
- package/content/references/base/datasources-reference.md +600 -0
- package/content/references/base/datasources.md +84 -444
- package/content/references/base/dependency-injection.md +25 -46
- package/content/references/base/filter-system/application-usage.md +95 -123
- package/content/references/base/filter-system/array-operators.md +33 -43
- package/content/references/base/filter-system/comparison-operators.md +55 -63
- package/content/references/base/filter-system/default-filter.md +144 -350
- package/content/references/base/filter-system/fields-order-pagination.md +116 -148
- package/content/references/base/filter-system/index.md +114 -253
- package/content/references/base/filter-system/json-filtering.md +52 -181
- package/content/references/base/filter-system/list-operators.md +28 -44
- package/content/references/base/filter-system/logical-operators.md +69 -114
- package/content/references/base/filter-system/null-operators.md +41 -98
- package/content/references/base/filter-system/pattern-matching.md +48 -51
- package/content/references/base/filter-system/quick-reference.md +93 -196
- package/content/references/base/filter-system/range-operators.md +22 -38
- package/content/references/base/filter-system/tips.md +70 -133
- package/content/references/base/filter-system/use-cases.md +173 -232
- package/content/references/base/grpc-controllers.md +53 -17
- package/content/references/base/index.md +5 -3
- package/content/references/base/middlewares.md +43 -28
- package/content/references/base/models-reference.md +886 -0
- package/content/references/base/models.md +81 -1452
- package/content/references/base/providers.md +8 -8
- package/content/references/base/repositories/advanced.md +281 -419
- package/content/references/base/repositories/index.md +84 -644
- package/content/references/base/repositories/mixins.md +25 -21
- package/content/references/base/repositories/relations.md +194 -375
- package/content/references/base/repositories/soft-deletable.md +67 -55
- package/content/references/base/secrets.md +267 -0
- package/content/references/base/services.md +8 -6
- package/content/references/configuration/environment-variables.md +73 -21
- package/content/references/configuration/index.md +51 -31
- package/content/references/index.md +1 -1
- package/content/references/quick-reference.md +3 -16
- package/content/references/utilities/crypto.md +35 -76
- package/content/references/utilities/date.md +33 -73
- package/content/references/utilities/duration.md +85 -0
- package/content/references/utilities/index.md +6 -2
- package/content/references/utilities/jsx-reference.md +298 -0
- package/content/references/utilities/jsx.md +82 -525
- package/content/references/utilities/module.md +81 -61
- package/content/references/utilities/parse.md +34 -64
- package/content/references/utilities/performance.md +33 -58
- package/content/references/utilities/promise.md +28 -62
- package/content/references/utilities/request.md +58 -218
- package/content/references/utilities/retry.md +139 -0
- package/content/references/utilities/schema.md +43 -137
- package/content/references/utilities/statuses-reference.md +361 -0
- package/content/references/utilities/statuses.md +63 -667
- package/dist/mcp-server/index.js +0 -0
- package/dist/mcp-server/tools/github/list-project-files.tool.d.ts +1 -1
- package/dist/mcp-server/tools/github/list-project-files.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/list-project-files.tool.js +3 -3
- package/dist/mcp-server/tools/github/search-code.tool.js +1 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.js +1 -1
- package/dist/mcp-server/tools/github/view-source-file.tool.js +1 -1
- package/package.json +24 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Health Check
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A minimal status endpoint for uptime monitoring - the default target for load balancer health checks and Kubernetes liveness probes.
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
@@ -17,200 +17,112 @@ import { HealthCheckComponent, HealthCheckBindingKeys } from '@venizia/ignis';
|
|
|
17
17
|
import type { IHealthCheckOptions } from '@venizia/ignis';
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## In one example
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Skip this step to use the default `/health` path. To customize the path:
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
import { HealthCheckBindingKeys, IHealthCheckOptions } from '@venizia/ignis';
|
|
28
|
-
|
|
29
|
-
// In your Application class's preConfigure method
|
|
30
|
-
this.bind<IHealthCheckOptions>({
|
|
31
|
-
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
32
|
-
}).toValue({
|
|
33
|
-
restOptions: { path: '/health-check' },
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Step 2: Register Component
|
|
22
|
+
Register the component with no configuration - `GET /health` and `POST /health/ping` are live immediately.
|
|
38
23
|
|
|
39
24
|
```typescript
|
|
40
|
-
import { HealthCheckComponent } from '@venizia/ignis';
|
|
25
|
+
import { HealthCheckComponent, BaseApplication, ValueOrPromise } from '@venizia/ignis';
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
export class Application extends BaseApplication {
|
|
28
|
+
preConfigure(): ValueOrPromise<void> {
|
|
29
|
+
this.component(HealthCheckComponent);
|
|
30
|
+
}
|
|
45
31
|
}
|
|
46
32
|
```
|
|
47
33
|
|
|
48
|
-
|
|
34
|
+
```bash
|
|
35
|
+
curl localhost:3000/health
|
|
36
|
+
# { "status": "ok" }
|
|
37
|
+
```
|
|
49
38
|
|
|
50
|
-
|
|
39
|
+
## How it works
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
- **Auto-registered controller.** `HealthCheckComponent.binding()` applies `@controller({ path })` to `HealthCheckController` via `Reflect.decorate` at runtime, then calls `this.application.controller(HealthCheckController)`. The path comes from DI, not a hardcoded class decorator.
|
|
42
|
+
- **Options are optional, field by field.** `IHealthCheckOptions.restOptions.path` is optional; a partially-filled binding (e.g., `{ restOptions: {} }`) still resolves. The component reads `healthOptions?.restOptions?.path ?? '/health'`, falling back per field rather than discarding the whole binding.
|
|
43
|
+
- **The default binding wins the race if you're late.** The constructor pre-binds `HEALTH_CHECK_OPTIONS` via `initDefault`, filling only an unbound key. A custom binding must exist BEFORE `this.component(HealthCheckComponent)` runs - otherwise the default has already claimed the slot.
|
|
44
|
+
- **Three route styles, one controller.** `HealthCheckController` demonstrates all three IGNIS route patterns - use it as a reference when picking a style for your own controllers:
|
|
54
45
|
|
|
55
|
-
|
|
46
|
+
| Style | API | Route |
|
|
47
|
+
|-------|-----|-------|
|
|
48
|
+
| Fluent | `bindRoute().to()` | `GET /` |
|
|
49
|
+
| Decorator | `@api()` | `POST /ping` |
|
|
50
|
+
| Imperative | `defineRoute()` (commented out in source) | - |
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|--------|------|---------|-------------|
|
|
59
|
-
| `restOptions.path` | `string` | `'/health'` | Base path for health endpoints |
|
|
52
|
+
## Common tasks
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
### Customize the health check path
|
|
55
|
+
Bind `IHealthCheckOptions` BEFORE registering the component - order matters (see above).
|
|
62
56
|
|
|
63
57
|
```typescript
|
|
64
|
-
|
|
65
|
-
restOptions: { path: '/health' },
|
|
66
|
-
};
|
|
67
|
-
```
|
|
58
|
+
import { HealthCheckBindingKeys, IHealthCheckOptions } from '@venizia/ignis';
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
this.bind<IHealthCheckOptions>({
|
|
61
|
+
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
62
|
+
}).toValue({ restOptions: { path: '/health-check' } });
|
|
63
|
+
|
|
64
|
+
this.component(HealthCheckComponent); // AFTER the bind
|
|
74
65
|
```
|
|
75
66
|
|
|
76
|
-
|
|
67
|
+
### Call the ping endpoint
|
|
68
|
+
`POST /health/ping` echoes `message` back with a server timestamp - useful for round-trip latency checks and body-parsing smoke tests.
|
|
77
69
|
|
|
78
|
-
|
|
70
|
+
```bash
|
|
71
|
+
curl -X POST localhost:3000/health/ping \
|
|
72
|
+
-H 'content-type: application/json' \
|
|
73
|
+
-d '{"message":"hello"}'
|
|
74
|
+
# { "type": "PONG", "date": "2026-02-11T12:00:00.000Z", "message": "hello" }
|
|
75
|
+
```
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
| Field | Type | Required | Constraints |
|
|
78
|
+
|-------|------|----------|-------------|
|
|
79
|
+
| `type` | `string` | No | Defaults to `"PING"` |
|
|
80
|
+
| `message` | `string` | Yes | Min 1, max 255 characters |
|
|
81
|
+
|
|
82
|
+
### Fix "health check endpoint returns 404"
|
|
83
|
+
Register the component in `preConfigure()`, before any controller registration completes.
|
|
81
84
|
|
|
82
85
|
```typescript
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
super({
|
|
87
|
-
scope: HealthCheckComponent.name,
|
|
88
|
-
initDefault: { enable: true, container: application },
|
|
89
|
-
bindings: {
|
|
90
|
-
[HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind<IHealthCheckOptions>({
|
|
91
|
-
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
92
|
-
}).toValue(DEFAULT_OPTIONS),
|
|
93
|
-
},
|
|
94
|
-
});
|
|
86
|
+
preConfigure(): ValueOrPromise<void> {
|
|
87
|
+
this.component(HealthCheckComponent);
|
|
88
|
+
// ... other registrations
|
|
95
89
|
}
|
|
96
90
|
```
|
|
97
91
|
|
|
98
|
-
|
|
92
|
+
## Reference
|
|
99
93
|
|
|
100
|
-
|
|
94
|
+
### Configuration
|
|
95
|
+
| Option | Type | Default | Description |
|
|
96
|
+
|--------|------|---------|-------------|
|
|
97
|
+
| `restOptions.path` | `string` (optional) | `'/health'` | Base path for health endpoints |
|
|
101
98
|
|
|
102
99
|
```typescript
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
107
|
-
isOptional: true,
|
|
108
|
-
}) ?? DEFAULT_OPTIONS;
|
|
109
|
-
|
|
110
|
-
Reflect.decorate(
|
|
111
|
-
[controller({ path: healthOptions.restOptions.path })],
|
|
112
|
-
HealthCheckController,
|
|
113
|
-
);
|
|
114
|
-
this.application.controller(HealthCheckController);
|
|
100
|
+
interface IHealthCheckOptions {
|
|
101
|
+
/** Partially-filled bindings are accepted; every missing field falls back to its default. */
|
|
102
|
+
restOptions?: { path?: string };
|
|
115
103
|
}
|
|
116
104
|
```
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
> The `@controller` decorator is applied dynamically during `binding()`, not statically on the class definition. This allows the path to be configured at runtime via DI bindings.
|
|
120
|
-
|
|
121
|
-
## Binding Keys
|
|
122
|
-
|
|
106
|
+
### Binding keys
|
|
123
107
|
| Key | Constant | Type | Required | Default |
|
|
124
108
|
|-----|----------|------|----------|---------|
|
|
125
109
|
| `@app/health-check/options` | `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS` | `IHealthCheckOptions` | No | `{ restOptions: { path: '/health' } }` |
|
|
126
110
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
### Rest Paths
|
|
131
|
-
|
|
132
|
-
| Constant | Value | Full Path (default) |
|
|
111
|
+
### REST paths
|
|
112
|
+
| Constant | Value | Full path (default) |
|
|
133
113
|
|----------|-------|---------------------|
|
|
134
114
|
| `HealthCheckRestPaths.ROOT` | `/` | `GET /health` |
|
|
135
115
|
| `HealthCheckRestPaths.PING` | `/ping` | `POST /health/ping` |
|
|
136
116
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
class HealthCheckRestPaths {
|
|
141
|
-
static readonly ROOT = '/'; // GET /health (or custom base path)
|
|
142
|
-
static readonly PING = '/ping'; // POST /health/ping (or custom base path + /ping)
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
The controller defines two internal route paths via `HealthCheckRestPaths`. These paths are relative to the base path configured in `IHealthCheckOptions.restOptions.path`.
|
|
147
|
-
|
|
148
|
-
## API Endpoints
|
|
117
|
+
Paths are relative to the base path configured in `IHealthCheckOptions.restOptions.path`.
|
|
149
118
|
|
|
119
|
+
### API endpoints
|
|
150
120
|
| Method | Path | Description | Response |
|
|
151
121
|
|--------|------|-------------|----------|
|
|
152
122
|
| `GET` | `/health` | Basic health check | `{ "status": "ok" }` |
|
|
153
123
|
| `POST` | `/health/ping` | Echo test | `{ "type": "PONG", "date": "...", "message": "..." }` |
|
|
154
124
|
|
|
155
|
-
###
|
|
156
|
-
|
|
157
|
-
Returns a simple health status object. Used by load balancers, Kubernetes liveness probes, and monitoring tools to verify the application is running.
|
|
158
|
-
|
|
159
|
-
### POST /health/ping
|
|
160
|
-
|
|
161
|
-
Echoes a message back with a server timestamp. Useful for:
|
|
162
|
-
- Verifying end-to-end connectivity
|
|
163
|
-
- Measuring round-trip latency
|
|
164
|
-
- Testing request body parsing
|
|
165
|
-
|
|
166
|
-
#### Request & Response Specifications
|
|
167
|
-
|
|
168
|
-
**GET /health**
|
|
169
|
-
|
|
170
|
-
Response `200`:
|
|
171
|
-
```json
|
|
172
|
-
{
|
|
173
|
-
"status": "ok"
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**POST /health/ping**
|
|
178
|
-
|
|
179
|
-
Request body:
|
|
180
|
-
```json
|
|
181
|
-
{
|
|
182
|
-
"type": "PING",
|
|
183
|
-
"message": "Any string here"
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
| Field | Type | Required | Constraints |
|
|
188
|
-
|-------|------|----------|-------------|
|
|
189
|
-
| `type` | `string` | No | Defaults to `"PING"` |
|
|
190
|
-
| `message` | `string` | Yes | Min 1, max 255 characters |
|
|
191
|
-
|
|
192
|
-
Response `200`:
|
|
193
|
-
```json
|
|
194
|
-
{
|
|
195
|
-
"type": "PONG",
|
|
196
|
-
"date": "2026-02-11T12:00:00.000Z",
|
|
197
|
-
"message": "Any string here"
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Route Definition Patterns
|
|
202
|
-
|
|
203
|
-
The `HealthCheckController` demonstrates all three route definition patterns supported by IGNIS:
|
|
204
|
-
|
|
205
|
-
| Pattern | Method | Used For |
|
|
206
|
-
|---------|--------|----------|
|
|
207
|
-
| **Fluent API** (`bindRoute().to()`) | Root health check (`GET /`) | Inline handlers, method chaining |
|
|
208
|
-
| **Imperative API** (`defineRoute()`) | (commented out in source) | Direct handler assignment in `binding()` |
|
|
209
|
-
| **Decorator API** (`@api()`) | Ping endpoint (`POST /ping`) | Class method handlers with OpenAPI metadata |
|
|
210
|
-
|
|
211
|
-
The controller uses `this.definitions = RouteConfigs` to store route configurations for introspection. This is optional but enables tools to discover available routes without invoking `binding()`.
|
|
212
|
-
|
|
213
|
-
#### Controller Source
|
|
125
|
+
### Controller source
|
|
214
126
|
```typescript
|
|
215
127
|
import {
|
|
216
128
|
BaseRestController, IControllerOptions, TRouteContext,
|
|
@@ -286,101 +198,15 @@ export class HealthCheckController extends BaseRestController {
|
|
|
286
198
|
}
|
|
287
199
|
```
|
|
288
200
|
|
|
289
|
-
#### Route Configuration Schemas
|
|
290
|
-
|
|
291
|
-
**Root endpoint (`GET /`):**
|
|
292
|
-
```typescript
|
|
293
|
-
const RouteConfigs = {
|
|
294
|
-
ROOT: {
|
|
295
|
-
method: HTTP.Methods.GET,
|
|
296
|
-
path: HealthCheckRestPaths.ROOT,
|
|
297
|
-
responses: jsonResponse({
|
|
298
|
-
schema: z.object({ status: z.string() }).openapi({
|
|
299
|
-
description: 'HealthCheck Schema',
|
|
300
|
-
examples: [{ status: 'ok' }],
|
|
301
|
-
}),
|
|
302
|
-
description: 'Health check status',
|
|
303
|
-
}),
|
|
304
|
-
},
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**Ping endpoint (`POST /ping`):**
|
|
308
|
-
```typescript
|
|
309
|
-
PING: {
|
|
310
|
-
method: HTTP.Methods.POST,
|
|
311
|
-
path: HealthCheckRestPaths.PING,
|
|
312
|
-
request: {
|
|
313
|
-
body: jsonContent({
|
|
314
|
-
description: 'PING | Request body',
|
|
315
|
-
schema: z.object({
|
|
316
|
-
type: z.string().optional().default('PING'),
|
|
317
|
-
message: z.string().min(1).max(255),
|
|
318
|
-
}),
|
|
319
|
-
}),
|
|
320
|
-
},
|
|
321
|
-
responses: jsonResponse({
|
|
322
|
-
schema: z.object({
|
|
323
|
-
type: z.string().optional().default('PONG'),
|
|
324
|
-
date: z.iso.datetime(),
|
|
325
|
-
message: z.string(),
|
|
326
|
-
}).openapi({
|
|
327
|
-
description: 'HealthCheck PingPong Schema',
|
|
328
|
-
examples: [{ date: new Date().toISOString(), message: 'ok' }],
|
|
329
|
-
}),
|
|
330
|
-
description: 'HealthCheck PingPong Message',
|
|
331
|
-
}),
|
|
332
|
-
},
|
|
333
|
-
} as const;
|
|
334
|
-
```
|
|
335
|
-
|
|
336
201
|
## Troubleshooting
|
|
337
202
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```typescript
|
|
345
|
-
preConfigure(): ValueOrPromise<void> {
|
|
346
|
-
this.component(HealthCheckComponent);
|
|
347
|
-
// ... other registrations
|
|
348
|
-
}
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
### "Custom path is not applied"
|
|
203
|
+
| Symptom | Cause | Fix |
|
|
204
|
+
|---------|-------|-----|
|
|
205
|
+
| `GET /health` returns 404 | `HealthCheckComponent` not registered, or registered after controllers were already mounted | Call `this.component(HealthCheckComponent)` in `preConfigure()` |
|
|
206
|
+
| Custom path not applied | Custom `IHealthCheckOptions` bound AFTER `this.component()` ran - the default binding already claimed the DI key | Bind options BEFORE calling `this.component(HealthCheckComponent)` |
|
|
207
|
+
| `POST /health/ping` returns a validation error | `message` is missing, or exceeds 255 characters | Send a `message` string between 1 and 255 characters |
|
|
352
208
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
**Fix:** Bind your custom options before calling `this.component(HealthCheckComponent)`:
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
preConfigure(): ValueOrPromise<void> {
|
|
359
|
-
// Bind options FIRST
|
|
360
|
-
this.bind<IHealthCheckOptions>({
|
|
361
|
-
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
362
|
-
}).toValue({
|
|
363
|
-
restOptions: { path: '/custom-health' },
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
// THEN register component
|
|
367
|
-
this.component(HealthCheckComponent);
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### "POST /health/ping returns validation error"
|
|
372
|
-
|
|
373
|
-
**Cause:** The request body is missing the required `message` field, or the `message` value exceeds the 255-character limit.
|
|
374
|
-
|
|
375
|
-
**Fix:** Ensure the request body includes a `message` string between 1 and 255 characters:
|
|
376
|
-
|
|
377
|
-
```json
|
|
378
|
-
{
|
|
379
|
-
"message": "hello"
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
## See Also
|
|
209
|
+
## See also
|
|
384
210
|
|
|
385
211
|
- **Guides:**
|
|
386
212
|
- [Components Overview](/guides/core-concepts/components) - Component system basics
|
|
@@ -391,3 +217,11 @@ preConfigure(): ValueOrPromise<void> {
|
|
|
391
217
|
|
|
392
218
|
- **Best Practices:**
|
|
393
219
|
- [Deployment Strategies](/best-practices/deployment-strategies) - Production monitoring
|
|
220
|
+
|
|
221
|
+
**Files:**
|
|
222
|
+
|
|
223
|
+
- [`packages/core-server/src/components/health-check/component.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core-server/src/components/health-check/component.ts) - `HealthCheckComponent`
|
|
224
|
+
- [`packages/core-server/src/components/health-check/controller.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core-server/src/components/health-check/controller.ts) - `HealthCheckController`
|
|
225
|
+
- [`packages/core-server/src/components/health-check/common/types.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core-server/src/components/health-check/common/types.ts) - `IHealthCheckOptions`
|
|
226
|
+
- [`packages/core-server/src/components/health-check/common/keys.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core-server/src/components/health-check/common/keys.ts) - `HealthCheckBindingKeys`
|
|
227
|
+
- [`packages/core-server/src/components/health-check/common/rest-paths.ts`](https://github.com/VENIZIA-AI/ignis/blob/main/packages/core-server/src/components/health-check/common/rest-paths.ts) - `HealthCheckRestPaths`
|
|
@@ -1,92 +1,26 @@
|
|
|
1
1
|
# Components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Built-in
|
|
6
|
-
|
|
7
|
-
| Component |
|
|
8
|
-
|
|
9
|
-
| [Authentication](./authentication/) | JWT
|
|
10
|
-
| [Authorization](./authorization/) <Badge type="warning" text="Experimental" /> | Enforcer-based
|
|
11
|
-
| [Health Check](./health-check) |
|
|
12
|
-
| [Mail](./mail/) | Email sending
|
|
13
|
-
| [Request Tracker](./request-tracker) | Request logging |
|
|
14
|
-
| [Socket.IO](./socket-io/) | Real-time
|
|
15
|
-
| [WebSocket](./websocket/) |
|
|
16
|
-
| [Static Asset](./static-asset/) |
|
|
17
|
-
| [
|
|
18
|
-
| [gRPC](/references/base/grpc-controllers) |
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export class MyCustomComponent extends BaseComponent {
|
|
28
|
-
constructor(
|
|
29
|
-
@inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,
|
|
30
|
-
) {
|
|
31
|
-
super({ scope: MyCustomComponent.name });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override binding(): ValueOrPromise<void> {
|
|
35
|
-
// This is where you bind your component's resources.
|
|
36
|
-
this.application.service(MyCustomService);
|
|
37
|
-
this.application.controller(MyCustomController);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Component Lifecycle
|
|
43
|
-
|
|
44
|
-
| Phase | When | Purpose |
|
|
45
|
-
|-------|------|---------|
|
|
46
|
-
| **`constructor()`** | Component instantiation | Receive dependencies, define default bindings |
|
|
47
|
-
| **`binding()`** | Application startup | Register controllers, services, repositories with DI container |
|
|
48
|
-
|
|
49
|
-
## Registering a Component
|
|
50
|
-
|
|
51
|
-
To use a component, you need to register it with the application instance, usually in the `preConfigure` method of your `Application` class.
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
// in src/application.ts
|
|
55
|
-
import { MyCustomComponent } from './components/my-custom.component';
|
|
56
|
-
|
|
57
|
-
// ... inside your Application class
|
|
58
|
-
|
|
59
|
-
preConfigure(): ValueOrPromise<void> {
|
|
60
|
-
// ...
|
|
61
|
-
this.component(MyCustomComponent);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
When the application starts, it will automatically call the `binding()` method of the registered component, setting up all the resources it provides.
|
|
66
|
-
|
|
67
|
-
Using components is a great way to organize your application's features into modular, reusable pieces of code, keeping your main application class clean and focused on high-level configuration.
|
|
68
|
-
|
|
69
|
-
## See Also
|
|
70
|
-
|
|
71
|
-
- **Component Guides:**
|
|
72
|
-
- [Components Overview](/guides/core-concepts/components) - What components are
|
|
73
|
-
- [Creating Components](/guides/core-concepts/components-guide) - Build your own components
|
|
74
|
-
|
|
75
|
-
- **Built-in Components:**
|
|
76
|
-
- [Authentication](./authentication/) - JWT/Basic authentication
|
|
77
|
-
- [Authorization](./authorization/) - Enforcer-based authorization
|
|
78
|
-
- [Health Check](./health-check) - Health check endpoints
|
|
79
|
-
- [Mail](./mail/) - Email functionality
|
|
80
|
-
- [Request Tracker](./request-tracker) - Request tracking
|
|
81
|
-
- [Socket.IO](./socket-io/) - Socket.IO WebSocket support
|
|
82
|
-
- [WebSocket](./websocket/) - Bun native WebSocket
|
|
83
|
-
- [Static Asset](./static-asset/) - File upload/download management
|
|
84
|
-
- [Swagger](./api-reference) - API documentation
|
|
85
|
-
- [gRPC](/references/base/grpc-controllers) - gRPC transport (ConnectRPC)
|
|
86
|
-
|
|
87
|
-
- **References:**
|
|
88
|
-
- [BaseComponent API](/references/base/components) - Component base class
|
|
89
|
-
- [Application](/references/base/application) - Registering components
|
|
90
|
-
|
|
91
|
-
- **Best Practices:**
|
|
92
|
-
- [Architectural Patterns](/best-practices/architectural-patterns) - Component design patterns
|
|
3
|
+
Self-contained feature modules you register with `this.component(SomeComponent)`.
|
|
4
|
+
|
|
5
|
+
## Built-in components
|
|
6
|
+
|
|
7
|
+
| Component | What it does | When you reach for it |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| [Authentication](./authentication/) | JWT and Basic auth - token generation, protected routes, multi-strategy | A route needs to know who the caller is |
|
|
10
|
+
| [Authorization](./authorization/) <Badge type="warning" text="Experimental" /> | Enforcer-based RBAC/ABAC, voters, Casbin integration | A route needs a permission check beyond authentication |
|
|
11
|
+
| [Health Check](./health-check) | `/health` endpoint, ping/pong | A load balancer or Kubernetes needs a liveness probe |
|
|
12
|
+
| [Mail](./mail/) | Email sending - multiple transports, templating, queue-based | The app sends transactional or templated email |
|
|
13
|
+
| [Request Tracker](./request-tracker) | Request ID, timing, structured request logging | Always on - registered automatically, nothing to configure |
|
|
14
|
+
| [Socket.IO](./socket-io/) | Real-time over Socket.IO - Redis adapter, event-based | Clients need rooms or Socket.IO-specific features |
|
|
15
|
+
| [WebSocket](./websocket/) | Native Bun WebSocket, Redis pub/sub, heartbeat | Clients need a raw WebSocket without Socket.IO |
|
|
16
|
+
| [Static Asset](./static-asset/) | Upload/download files - MinIO, Bun S3, local disk | The app stores or serves user-uploaded files |
|
|
17
|
+
| [API Reference](./api-reference) | OpenAPI generation, Scalar UI by default, Swagger UI optional | You want a browsable UI for your REST routes |
|
|
18
|
+
| [gRPC](/references/base/grpc-controllers) | ConnectRPC transport, unary RPC, decorator-based | The app serves gRPC alongside or instead of REST |
|
|
19
|
+
|
|
20
|
+
## See also
|
|
21
|
+
|
|
22
|
+
- [Components Overview](/guides/core-concepts/components) - What components are
|
|
23
|
+
- [Creating Components](/guides/core-concepts/components-guide) - Build your own
|
|
24
|
+
- [BaseComponent API](/references/base/components) - Component base class
|
|
25
|
+
- [Application](/references/base/application) - Registering components
|
|
26
|
+
- [Architectural Patterns](/best-practices/architectural-patterns) - Component design patterns
|