@venizia/ignis-docs 0.0.5 → 0.0.6-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/package.json +1 -1
- package/wiki/best-practices/architecture-decisions.md +0 -8
- package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
- 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/guides/core-concepts/components-guide.md +1 -1
- package/wiki/guides/core-concepts/components.md +2 -2
- package/wiki/guides/core-concepts/dependency-injection.md +1 -1
- package/wiki/guides/core-concepts/services.md +1 -1
- package/wiki/guides/tutorials/building-a-crud-api.md +1 -1
- package/wiki/guides/tutorials/ecommerce-api.md +2 -2
- package/wiki/guides/tutorials/realtime-chat.md +6 -6
- package/wiki/guides/tutorials/testing.md +1 -1
- package/wiki/references/base/bootstrapping.md +0 -2
- package/wiki/references/base/components.md +2 -2
- package/wiki/references/base/controllers.md +0 -1
- package/wiki/references/base/datasources.md +1 -1
- package/wiki/references/base/dependency-injection.md +1 -1
- package/wiki/references/base/filter-system/quick-reference.md +0 -14
- package/wiki/references/base/middlewares.md +0 -8
- package/wiki/references/base/providers.md +0 -9
- package/wiki/references/base/services.md +0 -1
- package/wiki/references/components/authentication/api.md +444 -0
- package/wiki/references/components/authentication/errors.md +177 -0
- package/wiki/references/components/authentication/index.md +571 -0
- package/wiki/references/components/authentication/usage.md +781 -0
- package/wiki/references/components/health-check.md +292 -103
- package/wiki/references/components/index.md +14 -12
- package/wiki/references/components/mail/api.md +505 -0
- package/wiki/references/components/mail/errors.md +176 -0
- package/wiki/references/components/mail/index.md +535 -0
- package/wiki/references/components/mail/usage.md +404 -0
- package/wiki/references/components/request-tracker.md +229 -25
- package/wiki/references/components/socket-io/api.md +1051 -0
- package/wiki/references/components/socket-io/errors.md +119 -0
- package/wiki/references/components/socket-io/index.md +410 -0
- package/wiki/references/components/socket-io/usage.md +322 -0
- package/wiki/references/components/static-asset/api.md +261 -0
- package/wiki/references/components/static-asset/errors.md +89 -0
- package/wiki/references/components/static-asset/index.md +617 -0
- package/wiki/references/components/static-asset/usage.md +364 -0
- package/wiki/references/components/swagger.md +390 -110
- package/wiki/references/components/template/api-page.md +125 -0
- package/wiki/references/components/template/errors-page.md +100 -0
- package/wiki/references/components/template/index.md +104 -0
- package/wiki/references/components/template/setup-page.md +134 -0
- package/wiki/references/components/template/single-page.md +132 -0
- package/wiki/references/components/template/usage-page.md +127 -0
- package/wiki/references/components/websocket/api.md +508 -0
- package/wiki/references/components/websocket/errors.md +123 -0
- package/wiki/references/components/websocket/index.md +453 -0
- package/wiki/references/components/websocket/usage.md +475 -0
- package/wiki/references/helpers/cron/index.md +224 -0
- package/wiki/references/helpers/crypto/index.md +537 -0
- package/wiki/references/helpers/env/index.md +214 -0
- package/wiki/references/helpers/error/index.md +232 -0
- package/wiki/references/helpers/index.md +16 -15
- package/wiki/references/helpers/inversion/index.md +608 -0
- package/wiki/references/helpers/logger/index.md +600 -0
- package/wiki/references/helpers/network/api.md +986 -0
- package/wiki/references/helpers/network/index.md +620 -0
- package/wiki/references/helpers/queue/index.md +589 -0
- package/wiki/references/helpers/redis/index.md +495 -0
- package/wiki/references/helpers/socket-io/api.md +497 -0
- package/wiki/references/helpers/socket-io/index.md +513 -0
- package/wiki/references/helpers/storage/api.md +705 -0
- package/wiki/references/helpers/storage/index.md +583 -0
- package/wiki/references/helpers/template/index.md +66 -0
- package/wiki/references/helpers/template/single-page.md +126 -0
- package/wiki/references/helpers/testing/index.md +510 -0
- package/wiki/references/helpers/types/index.md +512 -0
- package/wiki/references/helpers/uid/index.md +272 -0
- package/wiki/references/helpers/websocket/api.md +736 -0
- package/wiki/references/helpers/websocket/index.md +574 -0
- package/wiki/references/helpers/worker-thread/index.md +470 -0
- package/wiki/references/quick-reference.md +3 -18
- package/wiki/references/utilities/jsx.md +1 -8
- package/wiki/references/utilities/statuses.md +0 -7
- package/wiki/references/components/authentication.md +0 -476
- package/wiki/references/components/mail.md +0 -687
- package/wiki/references/components/socket-io.md +0 -562
- package/wiki/references/components/static-asset.md +0 -1277
- package/wiki/references/helpers/cron.md +0 -108
- package/wiki/references/helpers/crypto.md +0 -132
- package/wiki/references/helpers/env.md +0 -83
- package/wiki/references/helpers/error.md +0 -97
- package/wiki/references/helpers/inversion.md +0 -176
- package/wiki/references/helpers/logger.md +0 -296
- package/wiki/references/helpers/network.md +0 -396
- package/wiki/references/helpers/queue.md +0 -150
- package/wiki/references/helpers/redis.md +0 -142
- package/wiki/references/helpers/socket-io.md +0 -932
- package/wiki/references/helpers/storage.md +0 -665
- package/wiki/references/helpers/testing.md +0 -133
- package/wiki/references/helpers/types.md +0 -167
- package/wiki/references/helpers/uid.md +0 -167
- package/wiki/references/helpers/worker-thread.md +0 -178
|
@@ -1,45 +1,64 @@
|
|
|
1
|
-
# Health Check
|
|
1
|
+
# Health Check
|
|
2
2
|
|
|
3
|
-
Simple endpoint for monitoring application health
|
|
3
|
+
Simple endpoint for monitoring application health -- essential for microservices and containerized deployments.
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
7
|
-
|
|
|
8
|
-
|
|
9
|
-
| **
|
|
10
|
-
| **
|
|
7
|
+
| Item | Value |
|
|
8
|
+
|------|-------|
|
|
9
|
+
| **Package** | `@venizia/ignis` |
|
|
10
|
+
| **Class** | `HealthCheckComponent` |
|
|
11
|
+
| **Controller** | `HealthCheckController` |
|
|
12
|
+
| **Runtimes** | Both |
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
#### Import Paths
|
|
15
|
+
```typescript
|
|
16
|
+
import { HealthCheckComponent, HealthCheckBindingKeys } from '@venizia/ignis';
|
|
17
|
+
import type { IHealthCheckOptions } from '@venizia/ignis';
|
|
18
|
+
```
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|--------|------|---------|----------|
|
|
16
|
-
| `GET` | `/health` | Basic health check | `{ "status": "ok" }` |
|
|
17
|
-
| `POST` | `/health/ping` | Echo test | `{ "type": "PONG", "date": "...", "message": "..." }` |
|
|
20
|
+
## Setup
|
|
18
21
|
|
|
19
|
-
### Configuration
|
|
22
|
+
### Step 1: Bind Configuration (Optional)
|
|
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
|
+
```
|
|
20
36
|
|
|
21
|
-
|
|
22
|
-
|--------|---------|-------------|
|
|
23
|
-
| `restOptions.path` | `/health` | Base path for health endpoints |
|
|
37
|
+
### Step 2: Register Component
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
```typescript
|
|
40
|
+
import { HealthCheckComponent } from '@venizia/ignis';
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
preConfigure(): ValueOrPromise<void> {
|
|
43
|
+
// ... optional bindings from Step 1
|
|
44
|
+
this.component(HealthCheckComponent);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
30
47
|
|
|
31
|
-
|
|
48
|
+
### Step 3: Use
|
|
32
49
|
|
|
33
|
-
|
|
50
|
+
The health check endpoints are auto-registered -- no injection needed. Once the component is registered, `GET /health` and `POST /health/ping` are available immediately.
|
|
34
51
|
|
|
35
|
-
|
|
36
|
-
-
|
|
52
|
+
> [!TIP]
|
|
53
|
+
> If you customized the path in Step 1, the endpoints will be at your custom path instead (e.g., `GET /health-check` and `POST /health-check/ping`).
|
|
37
54
|
|
|
38
|
-
|
|
55
|
+
## Configuration
|
|
39
56
|
|
|
40
|
-
|
|
57
|
+
| Option | Type | Default | Description |
|
|
58
|
+
|--------|------|---------|-------------|
|
|
59
|
+
| `restOptions.path` | `string` | `'/health'` | Base path for health endpoints |
|
|
41
60
|
|
|
42
|
-
|
|
61
|
+
The component uses `IHealthCheckOptions` bound to `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`. If no custom binding is found, it falls back to:
|
|
43
62
|
|
|
44
63
|
```typescript
|
|
45
64
|
const DEFAULT_OPTIONS: IHealthCheckOptions = {
|
|
@@ -47,40 +66,161 @@ const DEFAULT_OPTIONS: IHealthCheckOptions = {
|
|
|
47
66
|
};
|
|
48
67
|
```
|
|
49
68
|
|
|
50
|
-
####
|
|
69
|
+
#### IHealthCheckOptions -- Full Reference
|
|
70
|
+
```typescript
|
|
71
|
+
interface IHealthCheckOptions {
|
|
72
|
+
restOptions: { path: string };
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The `path` value is applied via `@controller({ path })` decorator on `HealthCheckController` during the component's `binding()` phase. All controller routes are relative to this base path.
|
|
51
77
|
|
|
52
|
-
|
|
78
|
+
### Component Lifecycle
|
|
79
|
+
|
|
80
|
+
1. **`constructor()`** -- Receives `BaseApplication` via `@inject({ key: CoreBindings.APPLICATION_INSTANCE })`. Calls `super()` with `initDefault: { enable: true, container: application }` and provides default bindings for `HEALTH_CHECK_OPTIONS`:
|
|
53
81
|
|
|
54
82
|
```typescript
|
|
55
|
-
|
|
83
|
+
constructor(
|
|
84
|
+
@inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,
|
|
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
|
+
});
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The `initDefault: { enable: true, container: application }` option tells `BaseComponent` to automatically register all entries in `this.bindings` into the DI container before `binding()` is called. This happens inside `BaseComponent.configure()` via `initDefaultBindings()`, which iterates over `this.bindings` and calls `container.set()` for any key not already bound. This means users who bind their own `HEALTH_CHECK_OPTIONS` before registering the component will keep their custom value -- the default is only applied if the key is unbound.
|
|
56
99
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
100
|
+
2. **`binding()`** -- Reads options from the DI container using `application.get()` with `isOptional: true` and falls back to `DEFAULT_OPTIONS` via the `??` operator. Applies `@controller({ path })` decorator dynamically to `HealthCheckController` using `Reflect.decorate`. Registers the controller with the application:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
override binding(): ValueOrPromise<void> {
|
|
104
|
+
const healthOptions =
|
|
105
|
+
this.application.get<IHealthCheckOptions>({
|
|
61
106
|
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
107
|
+
isOptional: true,
|
|
108
|
+
}) ?? DEFAULT_OPTIONS;
|
|
109
|
+
|
|
110
|
+
Reflect.decorate(
|
|
111
|
+
[controller({ path: healthOptions.restOptions.path })],
|
|
112
|
+
HealthCheckController,
|
|
113
|
+
);
|
|
114
|
+
this.application.controller(HealthCheckController);
|
|
115
|
+
}
|
|
68
116
|
```
|
|
69
117
|
|
|
70
|
-
|
|
118
|
+
> [!NOTE]
|
|
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
|
+
|
|
123
|
+
| Key | Constant | Type | Required | Default |
|
|
124
|
+
|-----|----------|------|----------|---------|
|
|
125
|
+
| `@app/health-check/options` | `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS` | `IHealthCheckOptions` | No | `{ restOptions: { path: '/health' } }` |
|
|
71
126
|
|
|
72
|
-
|
|
127
|
+
> [!NOTE]
|
|
128
|
+
> The component provides a default binding for `HEALTH_CHECK_OPTIONS` via `initDefault`. You only need to bind this key if you want to customize the endpoint path. If you do bind it, do so **before** calling `this.component(HealthCheckComponent)` -- the `initDefaultBindings()` check uses `isBound()` and will skip keys that already exist in the container.
|
|
73
129
|
|
|
74
|
-
|
|
130
|
+
### Rest Paths
|
|
131
|
+
|
|
132
|
+
| Constant | Value | Full Path (default) |
|
|
133
|
+
|----------|-------|---------------------|
|
|
134
|
+
| `HealthCheckRestPaths.ROOT` | `/` | `GET /health` |
|
|
135
|
+
| `HealthCheckRestPaths.PING` | `/ping` | `POST /health/ping` |
|
|
136
|
+
|
|
137
|
+
### Rest Path Constants
|
|
75
138
|
|
|
76
139
|
```typescript
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
149
|
+
|
|
150
|
+
| Method | Path | Description | Response |
|
|
151
|
+
|--------|------|-------------|----------|
|
|
152
|
+
| `GET` | `/health` | Basic health check | `{ "status": "ok" }` |
|
|
153
|
+
| `POST` | `/health/ping` | Echo test | `{ "type": "PONG", "date": "...", "message": "..." }` |
|
|
154
|
+
|
|
155
|
+
### GET /health
|
|
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:
|
|
79
204
|
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
214
|
+
```typescript
|
|
215
|
+
import {
|
|
216
|
+
BaseController, IControllerOptions, TRouteContext,
|
|
217
|
+
api, jsonContent, jsonResponse, HTTP, z,
|
|
218
|
+
} from '@venizia/ignis';
|
|
219
|
+
|
|
220
|
+
const RouteConfigs = {
|
|
221
|
+
ROOT: {
|
|
82
222
|
method: HTTP.Methods.GET,
|
|
83
|
-
path:
|
|
223
|
+
path: HealthCheckRestPaths.ROOT,
|
|
84
224
|
responses: jsonResponse({
|
|
85
225
|
schema: z.object({ status: z.string() }).openapi({
|
|
86
226
|
description: 'HealthCheck Schema',
|
|
@@ -89,9 +229,9 @@ const ROUTE_CONFIGS = {
|
|
|
89
229
|
description: 'Health check status',
|
|
90
230
|
}),
|
|
91
231
|
},
|
|
92
|
-
|
|
232
|
+
PING: {
|
|
93
233
|
method: HTTP.Methods.POST,
|
|
94
|
-
path:
|
|
234
|
+
path: HealthCheckRestPaths.PING,
|
|
95
235
|
request: {
|
|
96
236
|
body: jsonContent({
|
|
97
237
|
description: 'PING | Request body',
|
|
@@ -117,26 +257,26 @@ const ROUTE_CONFIGS = {
|
|
|
117
257
|
},
|
|
118
258
|
} as const;
|
|
119
259
|
|
|
120
|
-
@controller({ path: '/health' }) // Base path is configured by options
|
|
121
260
|
export class HealthCheckController extends BaseController {
|
|
122
261
|
constructor(opts: IControllerOptions) {
|
|
123
262
|
super({ ...opts, scope: HealthCheckController.name });
|
|
124
|
-
|
|
125
|
-
this.definitions = ROUTE_CONFIGS;
|
|
263
|
+
this.definitions = RouteConfigs;
|
|
126
264
|
}
|
|
127
265
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
266
|
+
override binding(): ValueOrPromise<void> {
|
|
267
|
+
// Fluent API for the root health check
|
|
268
|
+
this.bindRoute({ configs: RouteConfigs.ROOT }).to({
|
|
269
|
+
handler: context => {
|
|
270
|
+
return context.json({ status: 'ok' }, HTTP.ResultCodes.RS_2.Ok);
|
|
271
|
+
},
|
|
272
|
+
});
|
|
131
273
|
}
|
|
132
274
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const { message } =
|
|
137
|
-
|
|
138
|
-
// Return type is automatically validated against the response schema
|
|
139
|
-
return c.json(
|
|
275
|
+
// Decorator API for the ping endpoint
|
|
276
|
+
@api({ configs: RouteConfigs.PING })
|
|
277
|
+
pingPong(context: TRouteContext) {
|
|
278
|
+
const { message } = context.req.valid<{ type?: string; message: string }>('json');
|
|
279
|
+
return context.json(
|
|
140
280
|
{ type: 'PONG', date: new Date().toISOString(), message },
|
|
141
281
|
HTTP.ResultCodes.RS_2.Ok,
|
|
142
282
|
);
|
|
@@ -144,59 +284,108 @@ export class HealthCheckController extends BaseController {
|
|
|
144
284
|
}
|
|
145
285
|
```
|
|
146
286
|
|
|
147
|
-
####
|
|
287
|
+
#### Route Configuration Schemas
|
|
148
288
|
|
|
149
|
-
|
|
289
|
+
**Root endpoint (`GET /`):**
|
|
290
|
+
```typescript
|
|
291
|
+
const RouteConfigs = {
|
|
292
|
+
ROOT: {
|
|
293
|
+
method: HTTP.Methods.GET,
|
|
294
|
+
path: HealthCheckRestPaths.ROOT,
|
|
295
|
+
responses: jsonResponse({
|
|
296
|
+
schema: z.object({ status: z.string() }).openapi({
|
|
297
|
+
description: 'HealthCheck Schema',
|
|
298
|
+
examples: [{ status: 'ok' }],
|
|
299
|
+
}),
|
|
300
|
+
description: 'Health check status',
|
|
301
|
+
}),
|
|
302
|
+
},
|
|
303
|
+
```
|
|
150
304
|
|
|
305
|
+
**Ping endpoint (`POST /ping`):**
|
|
151
306
|
```typescript
|
|
152
|
-
|
|
153
|
-
|
|
307
|
+
PING: {
|
|
308
|
+
method: HTTP.Methods.POST,
|
|
309
|
+
path: HealthCheckRestPaths.PING,
|
|
310
|
+
request: {
|
|
311
|
+
body: jsonContent({
|
|
312
|
+
description: 'PING | Request body',
|
|
313
|
+
schema: z.object({
|
|
314
|
+
type: z.string().optional().default('PING'),
|
|
315
|
+
message: z.string().min(1).max(255),
|
|
316
|
+
}),
|
|
317
|
+
}),
|
|
318
|
+
},
|
|
319
|
+
responses: jsonResponse({
|
|
320
|
+
schema: z.object({
|
|
321
|
+
type: z.string().optional().default('PONG'),
|
|
322
|
+
date: z.iso.datetime(),
|
|
323
|
+
message: z.string(),
|
|
324
|
+
}).openapi({
|
|
325
|
+
description: 'HealthCheck PingPong Schema',
|
|
326
|
+
examples: [{ date: new Date().toISOString(), message: 'ok' }],
|
|
327
|
+
}),
|
|
328
|
+
description: 'HealthCheck PingPong Message',
|
|
329
|
+
}),
|
|
330
|
+
},
|
|
331
|
+
} as const;
|
|
332
|
+
```
|
|
154
333
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
334
|
+
## Troubleshooting
|
|
335
|
+
|
|
336
|
+
### "Health check endpoint returns 404"
|
|
337
|
+
|
|
338
|
+
**Cause:** The `HealthCheckComponent` was not registered in your application, or it was registered after controllers were already mounted.
|
|
339
|
+
|
|
340
|
+
**Fix:** Register the component in `preConfigure()` before any controller registration:
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
preConfigure(): ValueOrPromise<void> {
|
|
344
|
+
this.component(HealthCheckComponent);
|
|
345
|
+
// ... other registrations
|
|
346
|
+
}
|
|
161
347
|
```
|
|
162
348
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
349
|
+
### "Custom path is not applied"
|
|
350
|
+
|
|
351
|
+
**Cause:** The custom `IHealthCheckOptions` binding was registered after the component. The component reads options during its `binding()` phase -- if no binding exists at that point, it uses the default `/health` path. However, because `HealthCheckComponent` uses `initDefault: { enable: true }`, it also registers a default binding before `binding()` runs. If you bind your custom options after calling `this.component()`, the default has already been set and your override will not take effect during the current lifecycle.
|
|
352
|
+
|
|
353
|
+
**Fix:** Bind your custom options before calling `this.component(HealthCheckComponent)`:
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
preConfigure(): ValueOrPromise<void> {
|
|
357
|
+
// Bind options FIRST
|
|
358
|
+
this.bind<IHealthCheckOptions>({
|
|
359
|
+
key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,
|
|
360
|
+
}).toValue({
|
|
361
|
+
restOptions: { path: '/custom-health' },
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// THEN register component
|
|
365
|
+
this.component(HealthCheckComponent);
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### "POST /health/ping returns validation error"
|
|
370
|
+
|
|
371
|
+
**Cause:** The request body is missing the required `message` field, or the `message` value exceeds the 255-character limit.
|
|
372
|
+
|
|
373
|
+
**Fix:** Ensure the request body includes a `message` string between 1 and 255 characters:
|
|
374
|
+
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"message": "hello"
|
|
378
|
+
}
|
|
379
|
+
```
|
|
191
380
|
|
|
192
381
|
## See Also
|
|
193
382
|
|
|
194
|
-
- **
|
|
383
|
+
- **Guides:**
|
|
195
384
|
- [Components Overview](/guides/core-concepts/components) - Component system basics
|
|
196
385
|
- [Application](/guides/core-concepts/application/) - Registering components
|
|
197
386
|
|
|
198
|
-
- **
|
|
199
|
-
- [Components
|
|
387
|
+
- **Components:**
|
|
388
|
+
- [All Components](./index) - Built-in components list
|
|
200
389
|
|
|
201
390
|
- **Best Practices:**
|
|
202
391
|
- [Deployment Strategies](/best-practices/deployment-strategies) - Production monitoring
|
|
@@ -6,13 +6,14 @@ Reusable, pluggable modules that group together related features. A component ca
|
|
|
6
6
|
|
|
7
7
|
| Component | Purpose | Key Features |
|
|
8
8
|
|-----------|---------|--------------|
|
|
9
|
-
| [Authentication](./authentication
|
|
10
|
-
| [Health Check](./health-check
|
|
11
|
-
| [Mail](./mail
|
|
12
|
-
| [Request Tracker](./request-tracker
|
|
13
|
-
| [Socket.IO](./socket-io
|
|
14
|
-
| [
|
|
15
|
-
| [
|
|
9
|
+
| [Authentication](./authentication/) | JWT/Basic auth | Token generation, protected routes, multi-strategy |
|
|
10
|
+
| [Health Check](./health-check) | Monitoring endpoint | `/health` endpoint, ping/pong functionality |
|
|
11
|
+
| [Mail](./mail/) | Email sending system | Multiple transports, templating, queue-based processing |
|
|
12
|
+
| [Request Tracker](./request-tracker) | Request logging | Request ID generation, timing, structured logging |
|
|
13
|
+
| [Socket.IO](./socket-io/) | Real-time communication | WebSocket support, Redis adapter, event-based |
|
|
14
|
+
| [WebSocket](./websocket/) | Real-time communication | Bun native WebSocket, Redis Pub/Sub, heartbeat |
|
|
15
|
+
| [Static Asset](./static-asset/) | File management | Upload/download files, MinIO & local filesystem support |
|
|
16
|
+
| [Swagger](./swagger) | API documentation | OpenAPI generation, Swagger UI, Scalar UI |
|
|
16
17
|
|
|
17
18
|
## Creating a Component
|
|
18
19
|
|
|
@@ -70,13 +71,14 @@ Using components is a great way to organize your application's features into mod
|
|
|
70
71
|
- [Creating Components](/guides/core-concepts/components-guide) - Build your own components
|
|
71
72
|
|
|
72
73
|
- **Built-in Components:**
|
|
73
|
-
- [Authentication](./authentication) - JWT authentication
|
|
74
|
+
- [Authentication](./authentication/) - JWT/Basic authentication
|
|
74
75
|
- [Health Check](./health-check) - Health check endpoints
|
|
75
|
-
- [
|
|
76
|
-
- [Socket.IO](./socket-io) - WebSocket support
|
|
77
|
-
- [Mail](./mail) - Email functionality
|
|
76
|
+
- [Mail](./mail/) - Email functionality
|
|
78
77
|
- [Request Tracker](./request-tracker) - Request tracking
|
|
79
|
-
- [
|
|
78
|
+
- [Socket.IO](./socket-io/) - Socket.IO WebSocket support
|
|
79
|
+
- [WebSocket](./websocket/) - Bun native WebSocket
|
|
80
|
+
- [Static Asset](./static-asset/) - Static file serving
|
|
81
|
+
- [Swagger](./swagger) - API documentation
|
|
80
82
|
|
|
81
83
|
- **References:**
|
|
82
84
|
- [BaseComponent API](/references/base/components) - Component base class
|