@venizia/ignis-docs 0.0.8 → 0.2.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/README.md +7 -7
- package/content/best-practices/api-usage-examples.md +15 -12
- package/content/best-practices/architectural-patterns.md +70 -78
- package/content/best-practices/architecture-decisions.md +91 -60
- package/content/best-practices/code-style-standards/advanced-patterns.md +56 -44
- package/content/best-practices/code-style-standards/constants-configuration.md +11 -11
- package/content/best-practices/code-style-standards/control-flow.md +5 -2
- package/content/best-practices/code-style-standards/documentation.md +13 -13
- package/content/best-practices/code-style-standards/function-patterns.md +9 -10
- package/content/best-practices/code-style-standards/index.md +1 -1
- package/content/best-practices/code-style-standards/naming-conventions.md +10 -8
- package/content/best-practices/code-style-standards/route-definitions.md +30 -12
- package/content/best-practices/code-style-standards/tooling.md +8 -5
- package/content/best-practices/code-style-standards/type-safety.md +13 -12
- package/content/best-practices/common-pitfalls.md +56 -37
- package/content/best-practices/contribution-workflow.md +13 -14
- package/content/best-practices/data-modeling.md +46 -22
- package/content/best-practices/deployment-strategies.md +28 -27
- package/content/best-practices/error-handling.md +48 -24
- package/content/best-practices/index.md +5 -5
- package/content/best-practices/performance-optimization.md +40 -31
- package/content/best-practices/security-guidelines.md +52 -23
- package/content/best-practices/testing-strategies.md +65 -51
- package/content/best-practices/troubleshooting-tips.md +24 -24
- package/content/extensions/components/{swagger.md → api-reference.md} +40 -31
- package/content/extensions/components/authentication/api.md +19 -19
- package/content/extensions/components/authentication/errors.md +7 -7
- package/content/extensions/components/authentication/index.md +10 -8
- package/content/extensions/components/authentication/usage.md +101 -6
- package/content/extensions/components/authorization/api.md +45 -25
- package/content/extensions/components/authorization/errors.md +6 -6
- package/content/extensions/components/authorization/index.md +11 -10
- package/content/extensions/components/authorization/usage.md +21 -21
- package/content/extensions/components/health-check.md +1 -1
- package/content/extensions/components/index.md +5 -5
- package/content/extensions/components/mail/errors.md +15 -15
- package/content/extensions/components/mail/index.md +1 -2
- package/content/extensions/components/mail/usage.md +1 -1
- package/content/extensions/components/request-tracker.md +1 -1
- package/content/extensions/components/socket-io/api.md +9 -9
- package/content/extensions/components/socket-io/errors.md +5 -5
- package/content/extensions/components/socket-io/index.md +8 -8
- package/content/extensions/components/socket-io/usage.md +1 -1
- package/content/extensions/components/static-asset/api.md +17 -4
- package/content/extensions/components/static-asset/errors.md +4 -4
- package/content/extensions/components/static-asset/index.md +26 -28
- package/content/extensions/components/static-asset/usage.md +13 -12
- package/content/extensions/components/template/index.md +2 -2
- package/content/extensions/components/template/setup-page.md +1 -1
- package/content/extensions/components/websocket/api.md +3 -3
- package/content/extensions/components/websocket/errors.md +5 -5
- package/content/extensions/components/websocket/index.md +5 -5
- package/content/extensions/components/websocket/usage.md +3 -3
- package/content/extensions/helpers/cron/index.md +2 -2
- package/content/extensions/helpers/crypto/index.md +1 -1
- package/content/extensions/helpers/env/index.md +27 -12
- package/content/extensions/helpers/error/index.md +81 -25
- package/content/extensions/helpers/index.md +2 -3
- package/content/extensions/helpers/inversion/index.md +15 -7
- package/content/extensions/helpers/kafka/compile-binary.md +92 -0
- package/content/extensions/helpers/kafka/examples.md +1 -1
- package/content/extensions/helpers/kafka/index.md +3 -0
- package/content/extensions/helpers/logger/index.md +32 -2
- package/content/extensions/helpers/network/index.md +6 -0
- package/content/extensions/helpers/queue/index.md +14 -17
- package/content/extensions/helpers/redis/index.md +548 -323
- package/content/extensions/helpers/socket-io/index.md +14 -10
- package/content/extensions/helpers/storage/api.md +44 -8
- package/content/extensions/helpers/storage/index.md +43 -7
- package/content/extensions/helpers/template/index.md +6 -3
- package/content/extensions/helpers/types/index.md +11 -8
- package/content/extensions/helpers/websocket/api.md +9 -9
- package/content/extensions/helpers/websocket/index.md +7 -7
- package/content/extensions/helpers/worker-thread/index.md +2 -2
- package/content/extensions/index.md +3 -4
- package/content/extensions/src-details/mcp-server.md +18 -24
- package/content/guides/core-concepts/application/bootstrapping.md +11 -14
- package/content/guides/core-concepts/application/index.md +3 -3
- package/content/guides/core-concepts/components.md +19 -10
- package/content/guides/core-concepts/dependency-injection.md +6 -3
- package/content/guides/core-concepts/grpc-controllers.md +6 -5
- package/content/guides/core-concepts/persistent/datasources.md +42 -43
- package/content/guides/core-concepts/persistent/index.md +16 -7
- package/content/guides/core-concepts/persistent/models.md +24 -20
- package/content/guides/core-concepts/persistent/postgres-drivers.md +201 -0
- package/content/guides/core-concepts/persistent/repositories.md +40 -23
- package/content/guides/core-concepts/persistent/search-meilisearch.md +185 -0
- package/content/guides/core-concepts/persistent/search-typesense.md +431 -0
- package/content/guides/core-concepts/persistent/transactions.md +61 -25
- package/content/guides/core-concepts/rest-controllers.md +12 -9
- package/content/guides/core-concepts/services.md +330 -60
- package/content/guides/get-started/5-minute-quickstart.md +15 -15
- package/content/guides/get-started/philosophy.md +36 -36
- package/content/guides/get-started/setup.md +3 -3
- package/content/guides/index.md +3 -3
- package/content/guides/migrations/redis-helpers-migration.md +177 -0
- package/content/guides/migrations/scoped-rbac-migration.md +17 -17
- package/content/guides/migrations/unified-connectors-migration.md +113 -0
- package/content/guides/reference/glossary.md +19 -12
- package/content/guides/reference/mcp-docs-server.md +22 -18
- package/content/guides/tutorials/building-a-crud-api.md +37 -44
- package/content/guides/tutorials/complete-installation.md +17 -17
- package/content/guides/tutorials/ecommerce-api.md +163 -124
- package/content/guides/tutorials/realtime-chat.md +181 -135
- package/content/guides/tutorials/testing.md +65 -523
- package/content/index.md +2 -180
- package/content/public/apple-touch-icon.png +0 -0
- package/content/public/og-image.png +0 -0
- package/content/public/site.webmanifest +11 -0
- package/content/references/base/application.md +4 -5
- package/content/references/base/bootstrapping.md +18 -5
- package/content/references/base/components.md +149 -120
- package/content/references/base/connectors.md +178 -0
- package/content/references/base/controllers.md +41 -30
- package/content/references/base/datasources.md +163 -92
- package/content/references/base/dependency-injection.md +34 -22
- package/content/references/base/filter-system/application-usage.md +17 -14
- package/content/references/base/filter-system/array-operators.md +7 -2
- package/content/references/base/filter-system/comparison-operators.md +3 -0
- package/content/references/base/filter-system/default-filter.md +89 -71
- package/content/references/base/filter-system/fields-order-pagination.md +22 -22
- package/content/references/base/filter-system/index.md +6 -3
- package/content/references/base/filter-system/json-filtering.md +20 -1
- package/content/references/base/filter-system/list-operators.md +1 -1
- package/content/references/base/filter-system/logical-operators.md +33 -1
- package/content/references/base/filter-system/null-operators.md +30 -1
- package/content/references/base/filter-system/quick-reference.md +23 -4
- package/content/references/base/filter-system/tips.md +5 -5
- package/content/references/base/filter-system/use-cases.md +12 -12
- package/content/references/base/grpc-controllers.md +13 -13
- package/content/references/base/index.md +24 -12
- package/content/references/base/middlewares.md +265 -327
- package/content/references/base/models.md +63 -49
- package/content/references/base/providers.md +136 -130
- package/content/references/base/repositories/advanced.md +59 -58
- package/content/references/base/repositories/index.md +115 -91
- package/content/references/base/repositories/mixins.md +55 -291
- package/content/references/base/repositories/relations.md +54 -64
- package/content/references/base/repositories/soft-deletable.md +31 -30
- package/content/references/base/services.md +296 -93
- package/content/references/configuration/environment-variables.md +49 -31
- package/content/references/configuration/index.md +6 -6
- package/content/references/index.md +17 -12
- package/content/references/quick-reference.md +65 -106
- package/content/references/utilities/crypto.md +65 -23
- package/content/references/utilities/index.md +3 -3
- package/content/references/utilities/jsx.md +6 -4
- package/content/references/utilities/module.md +68 -20
- package/content/references/utilities/parse.md +4 -14
- package/content/references/utilities/promise.md +9 -7
- package/content/references/utilities/schema.md +5 -3
- package/dist/mcp-server/common/guards.d.ts +8 -0
- package/dist/mcp-server/common/guards.d.ts.map +1 -0
- package/dist/mcp-server/common/guards.js +14 -0
- package/dist/mcp-server/common/guards.js.map +1 -0
- package/dist/mcp-server/common/index.d.ts +1 -0
- package/dist/mcp-server/common/index.d.ts.map +1 -1
- package/dist/mcp-server/common/index.js +1 -0
- package/dist/mcp-server/common/index.js.map +1 -1
- package/dist/mcp-server/helpers/docs.helper.d.ts.map +1 -1
- package/dist/mcp-server/helpers/docs.helper.js +4 -2
- package/dist/mcp-server/helpers/docs.helper.js.map +1 -1
- package/dist/mcp-server/helpers/github.helper.js +1 -1
- package/dist/mcp-server/index.js +7 -2
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/mcp-server/tools/base.tool.d.ts +6 -2
- package/dist/mcp-server/tools/base.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/base.tool.js.map +1 -1
- package/dist/mcp-server/tools/docs/search-documents.tool.d.ts +1 -1
- package/dist/mcp-server/tools/github/list-project-files.tool.d.ts +1 -1
- package/dist/mcp-server/tools/github/search-code.tool.d.ts +1 -1
- package/dist/mcp-server/tools/github/search-code.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/search-code.tool.js +4 -1
- package/dist/mcp-server/tools/github/search-code.tool.js.map +1 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.js +3 -1
- package/dist/mcp-server/tools/github/verify-dependencies.tool.js.map +1 -1
- package/package.json +9 -9
- package/content/extensions/helpers/testing/index.md +0 -510
- package/content/references/base/middleware.md +0 -347
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Environment Variables Reference
|
|
2
2
|
|
|
3
|
-
Complete reference of all environment variables used by
|
|
3
|
+
Complete reference of all environment variables used by IGNIS framework.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
IGNIS uses the `APP_ENV_` prefix for all framework-specific environment variables. This prevents conflicts with system variables like `PATH`, `HOME`, etc.
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
# ✅
|
|
11
|
+
# ✅ IGNIS variables
|
|
12
12
|
APP_ENV_POSTGRES_HOST=localhost
|
|
13
13
|
|
|
14
14
|
# ❌ Might conflict with system
|
|
@@ -96,9 +96,9 @@ APP_ENV_APPLICATION_ROLES=api,worker
|
|
|
96
96
|
|----------|----------|---------|-------------|
|
|
97
97
|
| `APP_ENV_SERVER_HOST` | No | `localhost` | Server bind address |
|
|
98
98
|
| `APP_ENV_SERVER_PORT` | No | `3000` | Server port |
|
|
99
|
-
| `APP_ENV_SERVER_BASE_PATH` | No |
|
|
100
|
-
| `HOST` | No | - | Alternative to `APP_ENV_SERVER_HOST` |
|
|
101
|
-
| `PORT` | No | - | Alternative to `APP_ENV_SERVER_PORT` |
|
|
99
|
+
| `APP_ENV_SERVER_BASE_PATH` | No | - | Base path convention (`EnvironmentKeys` constant; not read by the framework itself) |
|
|
100
|
+
| `HOST` | No | - | Alternative to `APP_ENV_SERVER_HOST` (takes precedence) |
|
|
101
|
+
| `PORT` | No | - | Alternative to `APP_ENV_SERVER_PORT` (takes precedence) |
|
|
102
102
|
|
|
103
103
|
### Example
|
|
104
104
|
|
|
@@ -116,11 +116,11 @@ APP_ENV_SERVER_BASE_PATH=/v1/api
|
|
|
116
116
|
|
|
117
117
|
### Priority Order
|
|
118
118
|
|
|
119
|
-
The server
|
|
120
|
-
1. Explicit config
|
|
121
|
-
2. `
|
|
122
|
-
3. `
|
|
123
|
-
4. Default values
|
|
119
|
+
The server host/port resolution uses this priority (`packages/core/src/base/applications/abstract.ts`):
|
|
120
|
+
1. Explicit config passed to the application constructor
|
|
121
|
+
2. `HOST`/`PORT` variables (for cloud platforms)
|
|
122
|
+
3. `APP_ENV_SERVER_HOST`/`APP_ENV_SERVER_PORT` variables
|
|
123
|
+
4. Default values (`localhost`/`3000`)
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
## Database Variables (PostgreSQL)
|
|
@@ -157,7 +157,9 @@ APP_ENV_POSTGRES_DATABASE=my_app_prod
|
|
|
157
157
|
### DataSource Configuration
|
|
158
158
|
|
|
159
159
|
```typescript
|
|
160
|
-
|
|
160
|
+
import { NodePostgresDriver } from '@venizia/ignis/postgres/node-postgres';
|
|
161
|
+
|
|
162
|
+
@datasource({ driver: NodePostgresDriver })
|
|
161
163
|
export class PostgresDataSource extends BaseDataSource {
|
|
162
164
|
constructor() {
|
|
163
165
|
super({
|
|
@@ -179,13 +181,15 @@ export class PostgresDataSource extends BaseDataSource {
|
|
|
179
181
|
|
|
180
182
|
| Variable | Required | Default | Description |
|
|
181
183
|
|----------|----------|---------|-------------|
|
|
182
|
-
| `APP_ENV_APPLICATION_SECRET` |
|
|
183
|
-
| `APP_ENV_JWT_SECRET` |
|
|
184
|
-
| `APP_ENV_JWT_EXPIRES_IN` | No |
|
|
184
|
+
| `APP_ENV_APPLICATION_SECRET` | Yes* | - | Secret for encrypting JWT payload |
|
|
185
|
+
| `APP_ENV_JWT_SECRET` | Yes* | - | Secret for signing JWT tokens |
|
|
186
|
+
| `APP_ENV_JWT_EXPIRES_IN` | No | - | Token expiration in seconds (e.g., `86400` = 24h) |
|
|
187
|
+
|
|
188
|
+
*Required by convention when using the authentication component - see below.
|
|
185
189
|
|
|
186
190
|
### Security Requirements
|
|
187
191
|
|
|
188
|
-
|
|
192
|
+
The `AuthenticateComponent` receives its secrets programmatically via the `jwtOptions` binding (`jwtSecret`, `getTokenExpiresFn`), not by reading these environment variables directly. These `EnvironmentKeys` constants are the conventional way for your application to supply those values. The component throws at startup if `jwtSecret` is missing or left at the placeholder value - so wiring it from an unset environment variable will fail the boot.
|
|
189
193
|
|
|
190
194
|
### Generate Strong Secrets
|
|
191
195
|
|
|
@@ -218,6 +222,12 @@ APP_ENV_JWT_EXPIRES_IN=86400
|
|
|
218
222
|
| Variable | Required | Default | Description |
|
|
219
223
|
|----------|----------|---------|-------------|
|
|
220
224
|
| `APP_ENV_LOGGER_FOLDER_PATH` | No | `./` | Directory for log files |
|
|
225
|
+
| `APP_ENV_LOGGER_FORMAT` | No | `text` | Log output format |
|
|
226
|
+
| `APP_ENV_LOGGER_INSPECT_DEPTH` | No | `5` | How deep a `%s` argument is inspected. Node hard-codes depth `0` for `%s`, which prints `[Object]` one level in; IGNIS widens it. Non-negative integers only - an absent, invalid or negative value falls back to `5` |
|
|
227
|
+
| `APP_ENV_LOGGER_FILE_FREQUENCY` | No | `1h` | Log file rotation frequency |
|
|
228
|
+
| `APP_ENV_LOGGER_FILE_MAX_SIZE` | No | `100m` | Max size per log file |
|
|
229
|
+
| `APP_ENV_LOGGER_FILE_MAX_FILES` | No | `5d` | Log file retention |
|
|
230
|
+
| `APP_ENV_LOGGER_FILE_DATE_PATTERN` | No | `YYYYMMDD_HH` | Rotated file date pattern |
|
|
221
231
|
| `APP_ENV_LOGGER_DGRAM_HOST` | No | - | UDP log transport host |
|
|
222
232
|
| `APP_ENV_LOGGER_DGRAM_PORT` | No | - | UDP log transport port |
|
|
223
233
|
| `APP_ENV_LOGGER_DGRAM_LABEL` | No | - | Label for UDP logs |
|
|
@@ -240,6 +250,9 @@ APP_ENV_LOGGER_DGRAM_LEVELS=error,warn,info
|
|
|
240
250
|
|
|
241
251
|
## Storage Variables (MinIO/S3)
|
|
242
252
|
|
|
253
|
+
> [!NOTE]
|
|
254
|
+
> These are application-level conventions (used by the `vert` reference application), not variables read by the framework. `MinioHelper` and the StaticAsset component receive their configuration programmatically - your application wires these values in.
|
|
255
|
+
|
|
243
256
|
| Variable | Required | Default | Description |
|
|
244
257
|
|----------|----------|---------|-------------|
|
|
245
258
|
| `APP_ENV_MINIO_HOST` | Yes* | - | MinIO/S3 endpoint |
|
|
@@ -248,7 +261,7 @@ APP_ENV_LOGGER_DGRAM_LEVELS=error,warn,info
|
|
|
248
261
|
| `APP_ENV_MINIO_SECRET_KEY` | Yes* | - | Secret key |
|
|
249
262
|
| `APP_ENV_MINIO_USE_SSL` | No | `false` | Enable SSL |
|
|
250
263
|
|
|
251
|
-
*Required when
|
|
264
|
+
*Required (by application convention) when wiring MinIO-backed storage.
|
|
252
265
|
|
|
253
266
|
### Example
|
|
254
267
|
|
|
@@ -271,17 +284,20 @@ APP_ENV_MINIO_USE_SSL=true
|
|
|
271
284
|
|
|
272
285
|
## Mail Variables
|
|
273
286
|
|
|
287
|
+
> [!NOTE]
|
|
288
|
+
> These are application-level conventions, not variables read by the framework. The Mail component's transporter receives its SMTP/OAuth2 configuration programmatically - your application wires these values in.
|
|
289
|
+
|
|
274
290
|
| Variable | Required | Default | Description |
|
|
275
291
|
|----------|----------|---------|-------------|
|
|
276
|
-
| `APP_ENV_MAIL_HOST` | Yes* | `smtp.gmail.com` |
|
|
277
|
-
| `APP_ENV_MAIL_PORT` | No |
|
|
278
|
-
| `APP_ENV_MAIL_SECURE` | No |
|
|
292
|
+
| `APP_ENV_MAIL_HOST` | Yes* | - | SMTP host (e.g., `smtp.gmail.com`) |
|
|
293
|
+
| `APP_ENV_MAIL_PORT` | No | - | SMTP port (e.g., `465`) |
|
|
294
|
+
| `APP_ENV_MAIL_SECURE` | No | - | Use TLS |
|
|
279
295
|
| `APP_ENV_MAIL_USER` | Yes* | - | SMTP username/email |
|
|
280
296
|
| `APP_ENV_MAIL_CLIENT_ID` | Yes* | - | OAuth2 client ID |
|
|
281
297
|
| `APP_ENV_MAIL_CLIENT_SECRET` | Yes* | - | OAuth2 client secret |
|
|
282
298
|
| `APP_ENV_MAIL_REFRESH_TOKEN` | Yes* | - | OAuth2 refresh token |
|
|
283
299
|
|
|
284
|
-
*Required when
|
|
300
|
+
*Required (by application convention) when wiring the Mail component with OAuth2.
|
|
285
301
|
|
|
286
302
|
### Example (Gmail with OAuth2)
|
|
287
303
|
|
|
@@ -310,14 +326,16 @@ APP_ENV_MAIL_REFRESH_TOKEN=your-oauth2-refresh-token
|
|
|
310
326
|
| Variable | Required | Default | Description |
|
|
311
327
|
|----------|----------|---------|-------------|
|
|
312
328
|
| `DEBUG` | No | - | Enable debug mode |
|
|
313
|
-
| `NODE_ENV` | No | `development` | Environment mode |
|
|
329
|
+
| `NODE_ENV` | No | `development` | Environment mode. One of `local`, `debug`, `development`, `dev`, `sit`, `uat`, `alpha`, `beta`, `staging`, `production` |
|
|
314
330
|
| `ALLOW_EMPTY_ENV_VALUE` | No | `false` | Allow empty env values |
|
|
315
331
|
|
|
332
|
+
The gate is fail-closed: an environment IGNIS does not recognise is treated as production, so error responses are sanitized. `local`, `debug`, `development`, `dev` and `sit` are the development environments - only they expose internal error detail. `alpha`, `beta`, `staging` and `production` stay sanitized.
|
|
333
|
+
|
|
316
334
|
### Example
|
|
317
335
|
|
|
318
336
|
```bash
|
|
319
|
-
# Development
|
|
320
|
-
NODE_ENV=
|
|
337
|
+
# Development - `dev` is an alias of `development`, and gets the same error detail
|
|
338
|
+
NODE_ENV=dev
|
|
321
339
|
DEBUG=true
|
|
322
340
|
|
|
323
341
|
# Production
|
|
@@ -347,20 +365,20 @@ project/
|
|
|
347
365
|
|
|
348
366
|
## Custom Environment Prefix
|
|
349
367
|
|
|
350
|
-
You can customize the prefix from `
|
|
368
|
+
You can customize the prefix from `APP_ENV` to something else via the `APPLICATION_ENV_PREFIX` variable. It is read once when `@venizia/ignis-helpers` loads, so set it in the shell (or before any framework import):
|
|
351
369
|
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
|
|
370
|
+
```bash
|
|
371
|
+
# Set custom prefix
|
|
372
|
+
APPLICATION_ENV_PREFIX=MY_APP
|
|
355
373
|
|
|
356
|
-
|
|
357
|
-
|
|
374
|
+
# Now use MY_APP_ prefix
|
|
375
|
+
MY_APP_POSTGRES_HOST=localhost
|
|
358
376
|
```
|
|
359
377
|
|
|
360
378
|
|
|
361
379
|
## Validation
|
|
362
380
|
|
|
363
|
-
|
|
381
|
+
On startup, IGNIS iterates every `APP_ENV_*` (prefixed) variable that is set and throws if any has an empty value (`validateEnvs` in `packages/core/src/base/applications/abstract.ts`). It does not check for variables that are absent entirely - component-level validation (e.g., the authentication component's `jwtSecret` check) covers required values.
|
|
364
382
|
|
|
365
383
|
### Disable Validation
|
|
366
384
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuration Reference
|
|
2
2
|
|
|
3
|
-
Configuration options and environment variables for
|
|
3
|
+
Configuration options and environment variables for IGNIS applications.
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
@@ -11,15 +11,15 @@ Configuration options and environment variables for Ignis applications.
|
|
|
11
11
|
| Database | PostgreSQL connection | `APP_ENV_POSTGRES_HOST`, `APP_ENV_POSTGRES_DATABASE` |
|
|
12
12
|
| Authentication | JWT tokens and secrets | `APP_ENV_JWT_SECRET`, `APP_ENV_APPLICATION_SECRET` |
|
|
13
13
|
| Logging | Log file paths and transports | `APP_ENV_LOGGER_FOLDER_PATH` |
|
|
14
|
-
| Storage | MinIO/S3 file storage | `APP_ENV_MINIO_HOST`, `APP_ENV_MINIO_ACCESS_KEY` |
|
|
15
|
-
| Mail | SMTP email sending | `APP_ENV_MAIL_HOST`, `APP_ENV_MAIL_USER` |
|
|
14
|
+
| Storage | MinIO/S3 file storage (application-level convention) | `APP_ENV_MINIO_HOST`, `APP_ENV_MINIO_ACCESS_KEY` |
|
|
15
|
+
| Mail | SMTP email sending (application-level convention) | `APP_ENV_MAIL_HOST`, `APP_ENV_MAIL_USER` |
|
|
16
16
|
|
|
17
17
|
## Environment Variable Prefix
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
IGNIS uses the `APP_ENV_` prefix to avoid conflicts with system variables:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
# ✅
|
|
22
|
+
# ✅ IGNIS variables
|
|
23
23
|
APP_ENV_POSTGRES_HOST=localhost
|
|
24
24
|
|
|
25
25
|
# ❌ Might conflict with system
|
|
@@ -69,7 +69,7 @@ project/
|
|
|
69
69
|
|
|
70
70
|
### 3. Validation on Startup
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
IGNIS validates every set `APP_ENV_*` variable on startup and fails with a clear error if any is empty (bypass with `ALLOW_EMPTY_ENV_VALUE=true`). Absent variables are not flagged - components validate their own required inputs.
|
|
73
73
|
|
|
74
74
|
> **Related:** [Environment Variables Reference](./environment-variables.md) | [DataSources Guide](../../guides/core-concepts/persistent/datasources)
|
|
75
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
Complete reference documentation for the
|
|
3
|
+
Complete reference documentation for the IGNIS framework. Find detailed API docs, type definitions, and usage examples for every class, component, and utility in the framework.
|
|
4
4
|
|
|
5
5
|
<div class="guide-cards">
|
|
6
6
|
|
|
@@ -63,7 +63,7 @@ Complete reference documentation for the Ignis framework. Find detailed API docs
|
|
|
63
63
|
<span class="stage-num">3</span>
|
|
64
64
|
<h4>Adding Features</h4>
|
|
65
65
|
</div>
|
|
66
|
-
<p><a href="/ignis/extensions/components/authentication/">Auth</a> → <a href="/ignis/extensions/components/socket-io/">Real-time</a> → <a href="/ignis/extensions/components/mail/">Email</a> → <a href="/ignis/extensions/components/
|
|
66
|
+
<p><a href="/ignis/extensions/components/authentication/">Auth</a> → <a href="/ignis/extensions/components/socket-io/">Real-time</a> → <a href="/ignis/extensions/components/mail/">Email</a> → <a href="/ignis/extensions/components/api-reference">API Docs</a></p>
|
|
67
67
|
<span class="stage-desc">Pre-built components for common features</span>
|
|
68
68
|
</div>
|
|
69
69
|
|
|
@@ -99,7 +99,7 @@ Complete reference documentation for the Ignis framework. Find detailed API docs
|
|
|
99
99
|
<span class="stage-num">7</span>
|
|
100
100
|
<h4>Testing & Quality</h4>
|
|
101
101
|
</div>
|
|
102
|
-
<p><a href="
|
|
102
|
+
<p><a href="./base/repositories/advanced">Mocking & Stubs</a> → <a href="./quick-reference">Best Practices</a></p>
|
|
103
103
|
<span class="stage-desc">Testing strategies, quality assurance, and code review</span>
|
|
104
104
|
</div>
|
|
105
105
|
|
|
@@ -123,18 +123,23 @@ class UserController extends BaseRestController {
|
|
|
123
123
|
|
|
124
124
|
**Query with Repository:**
|
|
125
125
|
```typescript
|
|
126
|
-
const users = await
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
const users = await userRepository.find({
|
|
127
|
+
filter: {
|
|
128
|
+
where: { isActive: true },
|
|
129
|
+
order: ['createdAt DESC'],
|
|
130
|
+
limit: 10,
|
|
131
|
+
},
|
|
130
132
|
});
|
|
131
133
|
```
|
|
132
134
|
|
|
133
135
|
**Schedule a Job:**
|
|
134
136
|
```typescript
|
|
135
|
-
CronHelper.
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
CronHelper.newInstance({
|
|
138
|
+
cronTime: '0 * * * *',
|
|
139
|
+
onTick: async () => {
|
|
140
|
+
await cleanupExpiredSessions();
|
|
141
|
+
},
|
|
142
|
+
}).start();
|
|
138
143
|
```
|
|
139
144
|
|
|
140
145
|
## Common Imports
|
|
@@ -156,7 +161,7 @@ import {
|
|
|
156
161
|
// Helpers
|
|
157
162
|
import {
|
|
158
163
|
LoggerFactory,
|
|
159
|
-
|
|
164
|
+
RedisSingleHelper,
|
|
160
165
|
QueueHelper,
|
|
161
166
|
} from '@venizia/ignis-helpers';
|
|
162
167
|
|
|
@@ -166,7 +171,7 @@ import { Container } from '@venizia/ignis-inversion';
|
|
|
166
171
|
|
|
167
172
|
## See Also
|
|
168
173
|
|
|
169
|
-
- [Getting Started](/guides/) - New to
|
|
174
|
+
- [Getting Started](/guides/) - New to IGNIS? Start here
|
|
170
175
|
- [Core Concepts](/guides/core-concepts/application/) - Deep dive into architecture
|
|
171
176
|
- [Best Practices](/best-practices/) - Production patterns
|
|
172
177
|
- [Changelogs](/changelogs/) - Version history
|
|
@@ -30,8 +30,6 @@ await app.start();
|
|
|
30
30
|
- `initialize()` - Bootstrap the application
|
|
31
31
|
- `start()` - Start HTTP server
|
|
32
32
|
- `stop()` - Stop server gracefully
|
|
33
|
-
- `get<T>(key)` - Resolve from DI container
|
|
34
|
-
- `mountControllers()` - Register controllers
|
|
35
33
|
|
|
36
34
|
### BaseRestController
|
|
37
35
|
|
|
@@ -85,7 +83,7 @@ class GreeterController extends BaseGrpcController {
|
|
|
85
83
|
```typescript
|
|
86
84
|
import { BaseService, injectable } from '@venizia/ignis';
|
|
87
85
|
|
|
88
|
-
@injectable()
|
|
86
|
+
@injectable({})
|
|
89
87
|
class UserService extends BaseService {
|
|
90
88
|
constructor() {
|
|
91
89
|
super({ scope: UserService.name });
|
|
@@ -93,7 +91,7 @@ class UserService extends BaseService {
|
|
|
93
91
|
|
|
94
92
|
async getUser(id: string) {
|
|
95
93
|
this.logger.info('Getting user', id);
|
|
96
|
-
return this.
|
|
94
|
+
return this.userRepository.findById({ id });
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
```
|
|
@@ -104,27 +102,25 @@ class UserService extends BaseService {
|
|
|
104
102
|
### DefaultCRUDRepository
|
|
105
103
|
|
|
106
104
|
```typescript
|
|
107
|
-
import { DefaultCRUDRepository } from '@venizia/ignis';
|
|
105
|
+
import { DefaultCRUDRepository, repository } from '@venizia/ignis';
|
|
108
106
|
import { User } from '../models';
|
|
107
|
+
import { PostgresDataSource } from '../datasources';
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
109
|
+
@repository({ model: User, dataSource: PostgresDataSource })
|
|
110
|
+
class UserRepository extends DefaultCRUDRepository<typeof User.schema> {
|
|
111
|
+
// No constructor needed - dataSource auto-injected from @repository decorator
|
|
114
112
|
}
|
|
115
113
|
```
|
|
116
114
|
|
|
117
115
|
**Key Methods:**
|
|
118
|
-
- `
|
|
119
|
-
- `
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
- `delete(id)` - Delete by ID (soft/hard based on config)
|
|
127
|
-
- `deleteMany(filter)` - Delete multiple
|
|
116
|
+
- `find({ filter })` - Find many with filter, returns `T[]`
|
|
117
|
+
- `findById({ id })` - Find by ID
|
|
118
|
+
- `findOne({ filter })` - Find single entity
|
|
119
|
+
- `count({ where? })` - Count entities
|
|
120
|
+
- `create({ data })` - Create single entity, returns `{ count, data }`
|
|
121
|
+
- `createAll({ data: [] })` - Create multiple entities, returns `{ count, data[] }`
|
|
122
|
+
- `updateById({ id, data })` - Update by ID
|
|
123
|
+
- `deleteById({ id })` - Delete by ID
|
|
128
124
|
|
|
129
125
|
### BaseEntity
|
|
130
126
|
|
|
@@ -132,10 +128,10 @@ class UserRepository extends DefaultCRUDRepository<User> {
|
|
|
132
128
|
import { BaseEntity, model } from '@venizia/ignis';
|
|
133
129
|
import { integer, text, pgTable } from 'drizzle-orm/pg-core';
|
|
134
130
|
|
|
135
|
-
@model()
|
|
131
|
+
@model({ type: 'entity' })
|
|
136
132
|
class User extends BaseEntity {
|
|
137
|
-
static readonly
|
|
138
|
-
static readonly schema = pgTable(User.
|
|
133
|
+
static readonly TABLE_NAME = 'users';
|
|
134
|
+
static readonly schema = pgTable(User.TABLE_NAME, {
|
|
139
135
|
id: integer('id').primaryKey(),
|
|
140
136
|
name: text('name').notNull(),
|
|
141
137
|
email: text('email').notNull().unique(),
|
|
@@ -144,7 +140,7 @@ class User extends BaseEntity {
|
|
|
144
140
|
```
|
|
145
141
|
|
|
146
142
|
**Key Properties:**
|
|
147
|
-
- `static
|
|
143
|
+
- `static TABLE_NAME` - Database table name
|
|
148
144
|
- `static schema` - Drizzle schema definition
|
|
149
145
|
- `static AUTHORIZATION_SUBJECT` - Authorization principal (auto-set from `@model` settings `authorize.principal`)
|
|
150
146
|
|
|
@@ -226,7 +222,7 @@ class UserController extends BaseRestController {
|
|
|
226
222
|
| Operator | SQL | Example |
|
|
227
223
|
|----------|-----|---------|
|
|
228
224
|
| `in` | `IN` | `{ status: { in: ['active', 'pending'] } }` |
|
|
229
|
-
| `
|
|
225
|
+
| `nin` | `NOT IN` | `{ status: { nin: ['deleted'] } }` |
|
|
230
226
|
|
|
231
227
|
### Pattern Matching
|
|
232
228
|
|
|
@@ -234,17 +230,8 @@ class UserController extends BaseRestController {
|
|
|
234
230
|
|----------|-----|---------|
|
|
235
231
|
| `like` | `LIKE` | `{ name: { like: '%john%' } }` |
|
|
236
232
|
| `ilike` | `ILIKE` | `{ email: { ilike: '%@gmail.com' } }` |
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
239
|
-
| `startsWith` | `LIKE 'value%'` | `{ name: { startsWith: 'John' } }` |
|
|
240
|
-
| `endsWith` | `LIKE '%value'` | `{ email: { endsWith: '@example.com' } }` |
|
|
241
|
-
|
|
242
|
-
### Null Operators
|
|
243
|
-
|
|
244
|
-
| Operator | SQL | Example |
|
|
245
|
-
|----------|-----|---------|
|
|
246
|
-
| `isNull` | `IS NULL` | `{ deletedAt: { isNull: true } }` |
|
|
247
|
-
| `isNotNull` | `IS NOT NULL` | `{ email: { isNotNull: true } }` |
|
|
233
|
+
| `nlike` | `NOT LIKE` | `{ name: { nlike: '%test%' } }` |
|
|
234
|
+
| `nilike` | `NOT ILIKE` | `{ email: { nilike: '%spam%' } }` |
|
|
248
235
|
|
|
249
236
|
### Logical Operators
|
|
250
237
|
|
|
@@ -262,61 +249,59 @@ class UserController extends BaseRestController {
|
|
|
262
249
|
| `containedBy` | `<@` | `{ tags: { containedBy: ['ts', 'js', 'go'] } }` |
|
|
263
250
|
| `overlaps` | `&&` | `{ tags: { overlaps: ['react', 'vue'] } }` |
|
|
264
251
|
|
|
265
|
-
### JSON Operators (PostgreSQL)
|
|
266
|
-
|
|
267
|
-
| Operator | Description | Example |
|
|
268
|
-
|----------|-------------|---------|
|
|
269
|
-
| `jsonPath` | Query JSON field | `{ metadata: { jsonPath: '$.user.name', eq: 'John' } }` |
|
|
270
|
-
|
|
271
|
-
|
|
272
252
|
## Common Filters
|
|
273
253
|
|
|
274
254
|
### Basic Find
|
|
275
255
|
|
|
276
256
|
```typescript
|
|
277
|
-
const users = await
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
257
|
+
const users = await userRepository.find({
|
|
258
|
+
filter: {
|
|
259
|
+
where: { isActive: true },
|
|
260
|
+
order: ['createdAt DESC'],
|
|
261
|
+
limit: 10,
|
|
262
|
+
offset: 0,
|
|
263
|
+
},
|
|
282
264
|
});
|
|
283
265
|
```
|
|
284
266
|
|
|
285
267
|
### With Multiple Conditions
|
|
286
268
|
|
|
287
269
|
```typescript
|
|
288
|
-
const users = await
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
270
|
+
const users = await userRepository.find({
|
|
271
|
+
filter: {
|
|
272
|
+
where: {
|
|
273
|
+
and: [
|
|
274
|
+
{ age: { gte: 18 } },
|
|
275
|
+
{ status: { in: ['active', 'pending'] } },
|
|
276
|
+
{ email: { ilike: '%@company.com' } },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
296
280
|
});
|
|
297
281
|
```
|
|
298
282
|
|
|
299
283
|
### With Relations
|
|
300
284
|
|
|
301
285
|
```typescript
|
|
302
|
-
const posts = await
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
where: { approved: true },
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
286
|
+
const posts = await postRepository.find({
|
|
287
|
+
filter: {
|
|
288
|
+
where: { published: true },
|
|
289
|
+
include: [
|
|
290
|
+
{ relation: 'author' },
|
|
291
|
+
{ relation: 'comments', scope: { where: { approved: true }, limit: 5 } },
|
|
292
|
+
],
|
|
293
|
+
},
|
|
311
294
|
});
|
|
312
295
|
```
|
|
313
296
|
|
|
314
297
|
### Selecting Fields
|
|
315
298
|
|
|
316
299
|
```typescript
|
|
317
|
-
const users = await
|
|
318
|
-
|
|
319
|
-
|
|
300
|
+
const users = await userRepository.find({
|
|
301
|
+
filter: {
|
|
302
|
+
where: { isActive: true },
|
|
303
|
+
fields: ['id', 'name', 'email'],
|
|
304
|
+
},
|
|
320
305
|
});
|
|
321
306
|
```
|
|
322
307
|
|
|
@@ -328,7 +313,7 @@ const users = await userRepo.find({
|
|
|
328
313
|
```typescript
|
|
329
314
|
import { injectable } from '@venizia/ignis';
|
|
330
315
|
|
|
331
|
-
@injectable()
|
|
316
|
+
@injectable({})
|
|
332
317
|
class MyService extends BaseService {
|
|
333
318
|
// ...
|
|
334
319
|
}
|
|
@@ -348,13 +333,6 @@ class UserController extends BaseRestController {
|
|
|
348
333
|
}
|
|
349
334
|
```
|
|
350
335
|
|
|
351
|
-
### Manual Resolution
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
const userService = app.get<UserService>('services.UserService');
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
|
|
358
336
|
## Common Imports
|
|
359
337
|
|
|
360
338
|
### Core Framework
|
|
@@ -408,21 +386,20 @@ import {
|
|
|
408
386
|
ApplicationLogger,
|
|
409
387
|
|
|
410
388
|
// Caching
|
|
411
|
-
|
|
389
|
+
RedisSingleHelper,
|
|
412
390
|
|
|
413
391
|
// Queues
|
|
414
392
|
QueueHelper,
|
|
415
393
|
|
|
416
394
|
// Crypto
|
|
417
395
|
hash,
|
|
418
|
-
compare,
|
|
419
396
|
|
|
420
397
|
// HTTP
|
|
421
398
|
HTTP,
|
|
422
399
|
} from '@venizia/ignis-helpers';
|
|
423
400
|
import { BullMQHelper } from '@venizia/ignis-helpers/bullmq';
|
|
424
401
|
import { CronHelper } from '@venizia/ignis-helpers/cron';
|
|
425
|
-
import {
|
|
402
|
+
import { MinioHelper } from '@venizia/ignis-helpers/minio';
|
|
426
403
|
```
|
|
427
404
|
|
|
428
405
|
### Dependency Injection
|
|
@@ -487,14 +464,17 @@ getDashboard(c: Context) {
|
|
|
487
464
|
import { Statuses } from '@venizia/ignis';
|
|
488
465
|
|
|
489
466
|
// Create with status
|
|
490
|
-
const order = await
|
|
491
|
-
|
|
492
|
-
|
|
467
|
+
const { data: order } = await orderRepository.create({
|
|
468
|
+
data: {
|
|
469
|
+
items: [...],
|
|
470
|
+
status: Statuses.PENDING,
|
|
471
|
+
},
|
|
493
472
|
});
|
|
494
473
|
|
|
495
474
|
// Update status
|
|
496
|
-
await
|
|
497
|
-
|
|
475
|
+
await orderRepository.updateById({
|
|
476
|
+
id: orderId,
|
|
477
|
+
data: { status: Statuses.COMPLETED },
|
|
498
478
|
});
|
|
499
479
|
|
|
500
480
|
// Check status
|
|
@@ -556,27 +536,6 @@ app.notFound(notFoundHandler({ logger: app.logger }));
|
|
|
556
536
|
```
|
|
557
537
|
|
|
558
538
|
|
|
559
|
-
## Environment Variables
|
|
560
|
-
|
|
561
|
-
### Loading Environment
|
|
562
|
-
|
|
563
|
-
```typescript
|
|
564
|
-
import { EnvHelper } from '@venizia/ignis-helpers';
|
|
565
|
-
|
|
566
|
-
// Load from .env file
|
|
567
|
-
EnvHelper.load();
|
|
568
|
-
|
|
569
|
-
// Get variable
|
|
570
|
-
const dbUrl = EnvHelper.get('DATABASE_URL');
|
|
571
|
-
|
|
572
|
-
// Get with default
|
|
573
|
-
const port = EnvHelper.get('PORT', '3000');
|
|
574
|
-
|
|
575
|
-
// Get required (throws if missing)
|
|
576
|
-
const apiKey = EnvHelper.getRequired('API_KEY');
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
|
|
580
539
|
## Common Patterns
|
|
581
540
|
|
|
582
541
|
### Controller → Service → Repository
|
|
@@ -605,7 +564,7 @@ class UserController extends BaseRestController {
|
|
|
605
564
|
class UserService extends BaseService {
|
|
606
565
|
constructor(
|
|
607
566
|
@inject({ key: 'repositories.UserRepository' })
|
|
608
|
-
private
|
|
567
|
+
private userRepository: UserRepository,
|
|
609
568
|
) {
|
|
610
569
|
super({ scope: UserService.name });
|
|
611
570
|
}
|
|
@@ -614,7 +573,7 @@ class UserService extends BaseService {
|
|
|
614
573
|
// Business logic
|
|
615
574
|
const hashedPassword = await hash({ value: data.password });
|
|
616
575
|
|
|
617
|
-
return this.
|
|
576
|
+
return this.userRepository.create({
|
|
618
577
|
data: {
|
|
619
578
|
...data,
|
|
620
579
|
password: hashedPassword,
|