@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
@@ -0,0 +1,214 @@
1
+ # Environment
2
+
3
+ Structured access to application environment variables with prefix filtering, type-safe retrieval, and stage detection.
4
+
5
+ ## Quick Reference
6
+
7
+ | Item | Value |
8
+ |------|-------|
9
+ | **Package** | `@venizia/ignis-helpers` |
10
+ | **Classes** | `ApplicationEnvironment`, `Environment` |
11
+ | **Extends** | `IApplicationEnvironment` (interface) |
12
+ | **Singleton** | `applicationEnvironment` -- auto-initialized at module load |
13
+ | **Runtimes** | Both |
14
+
15
+ #### Import Paths
16
+
17
+ ```typescript
18
+ // Singleton instance (recommended)
19
+ import { applicationEnvironment } from '@venizia/ignis-helpers';
20
+
21
+ // Classes
22
+ import { ApplicationEnvironment, Environment } from '@venizia/ignis-helpers';
23
+
24
+ // Interface
25
+ import type { IApplicationEnvironment } from '@venizia/ignis-helpers';
26
+ ```
27
+
28
+ ## Creating an Instance
29
+
30
+ ### Singleton (Recommended)
31
+
32
+ A pre-configured `applicationEnvironment` singleton is auto-initialized at module load time. It reads `process.env` and filters keys matching the configured prefix (default: `APP_ENV`).
33
+
34
+ ```typescript
35
+ import { applicationEnvironment } from '@venizia/ignis-helpers';
36
+
37
+ const jwtSecret = applicationEnvironment.get<string>('APP_ENV_JWT_SECRET');
38
+ ```
39
+
40
+ > [!TIP]
41
+ > For most applications, the singleton is all you need. It is created once at module load and shares the same filtered environment across your entire app.
42
+
43
+ ### Custom Instance
44
+
45
+ If you need a different prefix or a custom set of environment variables, construct your own instance.
46
+
47
+ ```typescript
48
+ import { ApplicationEnvironment } from '@venizia/ignis-helpers';
49
+
50
+ const customEnv = new ApplicationEnvironment({
51
+ prefix: 'MY_APP_ENV',
52
+ envs: process.env,
53
+ });
54
+
55
+ const host = customEnv.get<string>('MY_APP_ENV_SERVER_HOST');
56
+ ```
57
+
58
+ #### Constructor Options
59
+
60
+ | Option | Type | Default | Description |
61
+ |--------|------|---------|-------------|
62
+ | `prefix` | `string` | -- (required) | Only keys starting with this prefix are included |
63
+ | `envs` | `Record<string, string \| number \| undefined>` | -- (required) | The environment object to filter (typically `process.env`) |
64
+
65
+ The default singleton uses `process.env.APPLICATION_ENV_PREFIX ?? 'APP_ENV'` as the prefix and `process.env` as the environment source.
66
+
67
+ ## Usage
68
+
69
+ ### Reading Variables
70
+
71
+ Use `get<ReturnType>(key)` to retrieve a typed environment variable. Only keys matching the configured prefix are available.
72
+
73
+ ```typescript
74
+ import { applicationEnvironment } from '@venizia/ignis-helpers';
75
+
76
+ const jwtSecret = applicationEnvironment.get<string>('APP_ENV_JWT_SECRET');
77
+ const serverPort = applicationEnvironment.get<string>('APP_ENV_SERVER_PORT');
78
+ ```
79
+
80
+ > [!WARNING]
81
+ > `get<T>()` performs a TypeScript type cast, not a runtime conversion. All `process.env` values are strings. If the raw value is `"3000"`, `get<number>()` still returns the string at runtime. Parse it yourself if needed.
82
+
83
+ ### Setting Variables
84
+
85
+ Use `set<ValueType>(key, value)` to add or override a variable at runtime.
86
+
87
+ ```typescript
88
+ applicationEnvironment.set('APP_ENV_FEATURE_FLAG', 'enabled');
89
+ ```
90
+
91
+ ### Listing Keys
92
+
93
+ Use `keys()` to retrieve all filtered environment variable keys.
94
+
95
+ ```typescript
96
+ const allKeys = applicationEnvironment.keys();
97
+ // e.g. ['APP_ENV_SERVER_HOST', 'APP_ENV_SERVER_PORT', 'APP_ENV_JWT_SECRET']
98
+ ```
99
+
100
+ ### Checking Development Mode
101
+
102
+ Use `isDevelopment()` to check if `process.env.NODE_ENV` is `'development'`.
103
+
104
+ ```typescript
105
+ if (applicationEnvironment.isDevelopment()) {
106
+ // Enable verbose logging, seed data, etc.
107
+ }
108
+ ```
109
+
110
+ ### Environment Stage Detection
111
+
112
+ The `Environment` class provides static helpers for checking the current `NODE_ENV`.
113
+
114
+ ```typescript
115
+ import { Environment } from '@venizia/ignis-helpers';
116
+
117
+ // Read the current stage (falls back to 'development' if NODE_ENV is unset)
118
+ console.log(Environment.current);
119
+
120
+ // Check a specific stage
121
+ if (Environment.is({ name: 'staging' })) {
122
+ // Staging-only behavior
123
+ }
124
+ ```
125
+
126
+ #### Available Stages
127
+
128
+ | Constant | Value |
129
+ |----------|-------|
130
+ | `Environment.LOCAL` | `'local'` |
131
+ | `Environment.DEBUG` | `'debug'` |
132
+ | `Environment.DEVELOPMENT` | `'development'` |
133
+ | `Environment.ALPHA` | `'alpha'` |
134
+ | `Environment.BETA` | `'beta'` |
135
+ | `Environment.STAGING` | `'staging'` |
136
+ | `Environment.PRODUCTION` | `'production'` |
137
+
138
+ All stages are collected in `Environment.COMMON_ENVS` (a `Set<string>`), which is used internally by the Logger to determine whether debug logging should be active.
139
+
140
+ ### Configuring the Prefix
141
+
142
+ The default singleton reads `APPLICATION_ENV_PREFIX` from `process.env` to determine its prefix. Set this variable **before** any import of `@venizia/ignis-helpers`.
143
+
144
+ ```
145
+ APPLICATION_ENV_PREFIX=MY_APP_ENV
146
+
147
+ MY_APP_ENV_SERVER_HOST=0.0.0.0
148
+ MY_APP_ENV_SERVER_PORT=3000
149
+ ```
150
+
151
+ ### Integration with BaseApplication
152
+
153
+ The `applicationEnvironment` singleton is used by the framework's `BaseApplication` during startup to validate that all prefixed environment variables have non-empty values. If any key has an empty value, the application throws an error unless `ALLOW_EMPTY_ENV_VALUE` is set to a truthy value.
154
+
155
+ ```typescript
156
+ // This validation runs automatically during application initialization.
157
+ // To allow empty values, set in your environment:
158
+ ALLOW_EMPTY_ENV_VALUE=true
159
+ ```
160
+
161
+ ## Troubleshooting
162
+
163
+ ### `get()` returns `undefined`
164
+
165
+ **Cause:** The key does not start with the configured prefix, so it was filtered out during construction.
166
+
167
+ **Fix:** Ensure your `.env` keys use the correct prefix:
168
+
169
+ ```
170
+ # Wrong -- missing prefix
171
+ SERVER_PORT=3000
172
+
173
+ # Correct -- matches default prefix
174
+ APP_ENV_SERVER_PORT=3000
175
+ ```
176
+
177
+ ### Custom prefix not taking effect
178
+
179
+ **Cause:** `APPLICATION_ENV_PREFIX` must be set **before** the module loads. If it is set after import, the singleton is already constructed with the default `APP_ENV`.
180
+
181
+ **Fix:** Set the prefix in your `.env` file or at process start, before any import of `@venizia/ignis-helpers`:
182
+
183
+ ```
184
+ APPLICATION_ENV_PREFIX=MY_APP_ENV
185
+ ```
186
+
187
+ ### `get<number>()` returns a string
188
+
189
+ **Cause:** `get<T>()` performs a TypeScript type cast, not a runtime conversion. All `process.env` values are strings.
190
+
191
+ **Fix:** Parse the value explicitly:
192
+
193
+ ```typescript
194
+ const port = Number(applicationEnvironment.get<string>('APP_ENV_SERVER_PORT'));
195
+ ```
196
+
197
+ ### `[validateEnvs] Invalid Application Environment! Key: {key} | Value: {value}`
198
+
199
+ **Cause:** During application startup, `BaseApplication.validateEnvs()` found a prefixed environment key with an empty or undefined value.
200
+
201
+ **Fix:** Either provide a value for the key in your `.env` file, or allow empty values by setting:
202
+
203
+ ```
204
+ ALLOW_EMPTY_ENV_VALUE=true
205
+ ```
206
+
207
+ ## See Also
208
+
209
+ - **Guides:**
210
+ - [Application](/guides/core-concepts/application/) -- Environment validation during startup
211
+
212
+ - **Other Helpers:**
213
+ - [Helpers Index](../index) -- All available helpers
214
+ - [Logger](/references/helpers/logger/) -- Uses `Environment.COMMON_ENVS` for debug log filtering
@@ -0,0 +1,232 @@
1
+ # Error
2
+
3
+ Standardized error class and factory for throwing HTTP-aware errors with machine-readable codes across the application.
4
+
5
+ ## Quick Reference
6
+
7
+ | Item | Value |
8
+ |------|-------|
9
+ | **Package** | `@venizia/ignis-helpers` |
10
+ | **Class** | `ApplicationError` |
11
+ | **Extends** | `Error` (native) |
12
+ | **Runtimes** | Both |
13
+
14
+ #### Import Paths
15
+
16
+ ```typescript
17
+ import { ApplicationError, getError } from '@venizia/ignis-helpers';
18
+ import { ErrorSchema } from '@venizia/ignis-helpers';
19
+ import type { TError } from '@venizia/ignis-helpers';
20
+ ```
21
+
22
+ > [!NOTE]
23
+ > `ApplicationError`, `getError`, `ErrorSchema`, and `TError` are also available from `@venizia/ignis-inversion` and re-exported through `@venizia/ignis`.
24
+
25
+ ## Creating an Instance
26
+
27
+ `ApplicationError` extends the native `Error` class with an HTTP `statusCode` and an optional `messageCode` for machine-readable error identification.
28
+
29
+ ```typescript
30
+ import { ApplicationError, HTTP } from '@venizia/ignis-helpers';
31
+
32
+ const error = new ApplicationError({
33
+ message: 'User not found',
34
+ statusCode: HTTP.ResultCodes.RS_4.NotFound,
35
+ messageCode: 'USER_NOT_FOUND',
36
+ });
37
+ ```
38
+
39
+ #### Constructor Options (`TError`)
40
+
41
+ | Option | Type | Default | Description |
42
+ |--------|------|---------|-------------|
43
+ | `message` | `string` | -- (required) | Human-readable error message |
44
+ | `statusCode` | `number` | `400` | HTTP status code |
45
+ | `messageCode` | `string` | `undefined` | Machine-readable error code for client-side handling |
46
+ | `name` | `string` | `undefined` | Error name |
47
+
48
+ > [!TIP]
49
+ > The `TError` type is derived from `ErrorSchema` (a Zod schema) and uses `.catchall(z.any())`, so you can pass additional arbitrary properties beyond the four listed above.
50
+
51
+ #### `getError()` Factory Function
52
+
53
+ For convenience, use the standalone `getError()` function instead of calling `new ApplicationError()` directly. This is the preferred pattern throughout the Ignis codebase.
54
+
55
+ ```typescript
56
+ import { getError, HTTP } from '@venizia/ignis-helpers';
57
+
58
+ throw getError({
59
+ message: 'Invalid credentials',
60
+ statusCode: HTTP.ResultCodes.RS_4.Unauthorized,
61
+ messageCode: 'INVALID_CREDENTIALS',
62
+ });
63
+ ```
64
+
65
+ #### `ApplicationError.getError()` Static Method
66
+
67
+ An equivalent static factory method on the class itself:
68
+
69
+ ```typescript
70
+ throw ApplicationError.getError({
71
+ message: 'Configuration missing',
72
+ statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
73
+ });
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ ### Throwing Errors in Services
79
+
80
+ The most common pattern is throwing `ApplicationError` from service methods to signal HTTP-level failures. The framework's error handling middleware catches these and formats the response automatically.
81
+
82
+ ```typescript
83
+ import { getError, HTTP } from '@venizia/ignis-helpers';
84
+
85
+ class AuthenticationService {
86
+ async signUp(opts: { username: string; credential: string }) {
87
+ const existingUser = await this.userRepository.findByUsername(opts.username);
88
+ if (existingUser) {
89
+ throw getError({
90
+ statusCode: HTTP.ResultCodes.RS_4.Conflict,
91
+ message: 'Username already exists',
92
+ });
93
+ }
94
+ // ...
95
+ }
96
+ }
97
+ ```
98
+
99
+ ### Using `messageCode` for Client-Side Handling
100
+
101
+ The `messageCode` field allows frontend applications to map errors to localized messages or specific UI behaviors without parsing the human-readable `message` string.
102
+
103
+ ```typescript
104
+ throw getError({
105
+ message: 'Email verification required before login',
106
+ statusCode: HTTP.ResultCodes.RS_4.Forbidden,
107
+ messageCode: 'auth.email_not_verified',
108
+ });
109
+ ```
110
+
111
+ ### Error Response Format
112
+
113
+ The built-in `appErrorHandler` middleware (from `@venizia/ignis`) catches `ApplicationError` instances and formats them into consistent JSON responses. The response shape differs by environment.
114
+
115
+ #### Production Response
116
+
117
+ ```json
118
+ {
119
+ "message": "User not found",
120
+ "statusCode": 404,
121
+ "requestId": "abc-123-def"
122
+ }
123
+ ```
124
+
125
+ #### Development Response
126
+
127
+ In development (`NODE_ENV=development`), additional debugging fields are included:
128
+
129
+ ```json
130
+ {
131
+ "message": "User not found",
132
+ "statusCode": 404,
133
+ "requestId": "abc-123-def",
134
+ "details": {
135
+ "url": "http://localhost:3000/api/users/123",
136
+ "path": "/api/users/123",
137
+ "stack": "Error: User not found\n at ...",
138
+ "cause": "..."
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### ErrorSchema (Zod)
144
+
145
+ `ErrorSchema` is a Zod object schema used for OpenAPI response documentation. It is typically referenced in route definitions to describe error responses.
146
+
147
+ ```typescript
148
+ import { ErrorSchema, HTTP } from '@venizia/ignis-helpers';
149
+
150
+ // In route definition responses
151
+ const responses = {
152
+ [HTTP.ResultCodes.RS_4.NotFound]: {
153
+ description: 'Resource not found',
154
+ content: {
155
+ 'application/json': { schema: ErrorSchema },
156
+ },
157
+ },
158
+ };
159
+ ```
160
+
161
+ The schema shape:
162
+
163
+ ```typescript
164
+ const ErrorSchema = z
165
+ .object({
166
+ name: z.string().optional(),
167
+ statusCode: z.number().optional(),
168
+ messageCode: z.string().optional(),
169
+ message: z.string(),
170
+ })
171
+ .catchall(z.any());
172
+ ```
173
+
174
+ ### Common Status Code Patterns
175
+
176
+ | Scenario | Status Code | `HTTP.ResultCodes` Path |
177
+ |----------|-------------|-------------------------|
178
+ | Invalid input / bad request | 400 | `RS_4.BadRequest` |
179
+ | Missing or invalid auth | 401 | `RS_4.Unauthorized` |
180
+ | Insufficient permissions | 403 | `RS_4.Forbidden` |
181
+ | Resource not found | 404 | `RS_4.NotFound` |
182
+ | Duplicate resource | 409 | `RS_4.Conflict` |
183
+ | Validation error | 422 | `RS_4.UnprocessableEntity` |
184
+ | Server failure | 500 | `RS_5.InternalServerError` |
185
+
186
+ ## Troubleshooting
187
+
188
+ ### `statusCode` defaults to 400
189
+
190
+ **Cause:** `getError()` was called without specifying a `statusCode`. The `ApplicationError` constructor defaults to `400` (Bad Request).
191
+
192
+ **Fix:** Always provide an explicit status code using `HTTP.ResultCodes`:
193
+
194
+ ```typescript
195
+ throw getError({
196
+ message: 'Resource not found',
197
+ statusCode: HTTP.ResultCodes.RS_4.NotFound,
198
+ });
199
+ ```
200
+
201
+ ### Error response missing `stack` and `cause`
202
+
203
+ **Cause:** The application is running in production mode. The `appErrorHandler` middleware strips `stack`, `cause`, `url`, and `path` from responses when `NODE_ENV` is not `development`.
204
+
205
+ **Fix:** Set `NODE_ENV=development` to see full error details during debugging.
206
+
207
+ ### Errors returning 500 instead of expected status code
208
+
209
+ **Cause:** A plain `Error` (not `ApplicationError`) was thrown. The `appErrorHandler` middleware only reads `statusCode` from errors that have that property. Native `Error` instances default to `500`.
210
+
211
+ **Fix:** Use `getError()` or `new ApplicationError()` instead of `new Error()`:
212
+
213
+ ```typescript
214
+ // Incorrect -- will return 500
215
+ throw new Error('Not found');
216
+
217
+ // Correct -- will return 404
218
+ throw getError({
219
+ message: 'Not found',
220
+ statusCode: HTTP.ResultCodes.RS_4.NotFound,
221
+ });
222
+ ```
223
+
224
+ ## See Also
225
+
226
+ - [Controllers](/references/base/controllers) -- Throwing errors in route handlers
227
+ - [Services](/references/base/services) -- Error handling in business logic
228
+ - [Middlewares](/references/base/middlewares) -- The `appErrorHandler` middleware
229
+ - [Helpers Index](/references/helpers/) -- All available helpers
230
+ - [Logger Helper](/references/helpers/logger/) -- Logging errors
231
+ - [Error Handling Best Practices](/best-practices/error-handling) -- Patterns and anti-patterns
232
+ - [Common Pitfalls](/best-practices/common-pitfalls) -- Frequent error handling mistakes
@@ -6,21 +6,22 @@ Reusable classes and functions providing common functionality - designed for eas
6
6
 
7
7
  | Helper | Purpose | Key Features |
8
8
  |--------|---------|--------------|
9
- | [Common Types](./types.md) | Utility types | Nullable, resolvers, class types |
10
- | [Cron](./cron.md) | Job scheduling | Cron expressions, task management |
11
- | [Crypto](./crypto.md) | Cryptographic operations | Hashing, AES/RSA encryption/decryption |
12
- | [Environment](./env.md) | Environment variables | Centralized config access |
13
- | [Error](./error.md) | Error handling | `ApplicationError`, consistent responses |
14
- | [Inversion](./inversion.md) | Dependency injection | DI container implementation |
15
- | [Logger](./logger.md) | Logging | Winston-based, multiple transports, scopes |
16
- | [Network](./network.md) | Network requests | HTTP, TCP, UDP helpers |
17
- | [Queue](./queue.md) | Message queues | BullMQ, MQTT support |
18
- | [Redis](./redis.md) | Redis operations | Single/cluster, key-value, hashes, JSON, pub/sub |
19
- | [Socket.IO](./socket-io.md) | Real-time communication | Socket.IO client/server helpers |
20
- | [Storage](./storage.md) | File storage | In-memory, Minio object storage |
21
- | [Testing](./testing.md) | Test utilities | Test plan runner, base test classes |
22
- | [UID](./uid.md) | Unique ID generation | Snowflake IDs, Base62 encoding |
23
- | [Worker Thread](./worker-thread.md) | Worker threads | Node.js worker management |
9
+ | [Common Types](./types/) | Utility types | Nullable, resolvers, class types |
10
+ | [Cron](./cron/) | Job scheduling | Cron expressions, task management |
11
+ | [Crypto](./crypto/) | Cryptographic operations | AES/RSA/ECDH encryption, key exchange, hashing |
12
+ | [Environment](./env/) | Environment variables | Centralized config access |
13
+ | [Error](./error/) | Error handling | `ApplicationError`, consistent responses |
14
+ | [Inversion](./inversion/) | Dependency injection | DI container implementation |
15
+ | [Logger](./logger/) | Logging | Winston-based, multiple transports, scopes |
16
+ | [Network](./network/) | Network requests | HTTP, TCP, UDP helpers |
17
+ | [Queue](./queue/) | Message queues | BullMQ, MQTT support |
18
+ | [Redis](./redis/) | Redis operations | Single/cluster, key-value, hashes, JSON, pub/sub |
19
+ | [Socket.IO](./socket-io/) | Real-time communication | Socket.IO client/server helpers |
20
+ | [WebSocket](./websocket/) | Real-time communication | Bun native WebSocket server/emitter, Redis scaling |
21
+ | [Storage](./storage/) | File storage | In-memory, Minio object storage |
22
+ | [Testing](./testing/) | Test utilities | Test plan runner, base test classes |
23
+ | [UID](./uid/) | Unique ID generation | Snowflake IDs, Base62 encoding |
24
+ | [Worker Thread](./worker-thread/) | Worker threads | Node.js worker management |
24
25
 
25
26
  ## See Also
26
27