@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,6 +1,9 @@
|
|
|
1
1
|
# Transactions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
IGNIS supports explicit transaction objects that can be passed across multiple services and repositories, allowing for complex, multi-step business logic to be atomic.
|
|
4
|
+
|
|
5
|
+
> [!NOTE] PostgreSQL-only capability
|
|
6
|
+
> Real transactions are a **PostgreSQL connector** capability - `BasePostgresDataSource.getCapabilities()` returns `{ transactions: true }` and its `beginTransaction()` opens a real database transaction, as documented below. The typesense connector inherits the engine-neutral `AbstractDataSource` default: calling `beginTransaction()` on it throws a `501 Not Implemented` (`messageCode: 'core.not_supported'`) via the shared `throwNotSupported` utility. See [Connectors](/references/base/connectors) for the capabilities model.
|
|
4
7
|
|
|
5
8
|
## Using Transactions
|
|
6
9
|
|
|
@@ -14,8 +17,8 @@ const tx = await userRepo.beginTransaction({
|
|
|
14
17
|
|
|
15
18
|
try {
|
|
16
19
|
// 2. Pass transaction to operations
|
|
17
|
-
// Create user
|
|
18
|
-
const user = await userRepo.create({
|
|
20
|
+
// Create user (write methods return a { count, data } envelope)
|
|
21
|
+
const { data: user } = await userRepo.create({
|
|
19
22
|
data: userData,
|
|
20
23
|
options: { transaction: tx }
|
|
21
24
|
});
|
|
@@ -32,29 +35,54 @@ try {
|
|
|
32
35
|
// 3. Commit the transaction
|
|
33
36
|
await tx.commit();
|
|
34
37
|
} catch (err) {
|
|
35
|
-
// 4. Rollback on error
|
|
36
|
-
await tx.rollback()
|
|
37
|
-
|
|
38
|
+
// 4. Rollback on error. Nest it: rollback() throws if ROLLBACK itself fails, and a bare
|
|
39
|
+
// `await tx.rollback()` here would replace `err` with the rollback error.
|
|
40
|
+
try {
|
|
41
|
+
await tx.rollback();
|
|
42
|
+
} catch (rollbackError) {
|
|
43
|
+
logger.error('Rollback failed | %s', rollbackError);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw err; // the original cause survives
|
|
38
47
|
}
|
|
39
48
|
```
|
|
40
49
|
|
|
50
|
+
> [!WARNING] `commit()` and `rollback()` throw on failure
|
|
51
|
+
> `COMMIT` can genuinely fail - a deadlock, a serialization failure under `SERIALIZABLE`, a dropped
|
|
52
|
+
> connection, a deferred constraint firing at commit time. When it does, `commit()` throws rather
|
|
53
|
+
> than resolving, so you never report success on a write that was never persisted. The connection is
|
|
54
|
+
> then destroyed instead of being returned to the pool, because it may still hold an open
|
|
55
|
+
> transaction that the next borrower would inherit.
|
|
56
|
+
>
|
|
57
|
+
> `rollback()` behaves the same way when it is the FIRST verb to fail. One deliberate exception
|
|
58
|
+
> keeps the everyday `catch { await tx.rollback(); throw error; }` pattern safe: calling
|
|
59
|
+
> `rollback()` on a transaction that already ended BY FAILURE (a failed `COMMIT` or a failed prior
|
|
60
|
+
> `ROLLBACK`) is a silent no-op - nothing was committed and the connection is already destroyed, so
|
|
61
|
+
> the rollback's goal is achieved and your original error survives. The nested-try form above is
|
|
62
|
+
> still the safest general pattern, because a FIRST rollback that itself fails does throw.
|
|
63
|
+
>
|
|
64
|
+
> The destroy half is **driver-specific**: node-postgres (`pg`) discards the poisoned connection,
|
|
65
|
+
> but postgres-js has no destroy semantics (`ReservedSql.release()` takes no argument), so under the
|
|
66
|
+
> postgres-js driver the connection returns to the pool anyway. See
|
|
67
|
+
> [Postgres Drivers & Supabase](./postgres-drivers) for the full asymmetry.
|
|
68
|
+
|
|
41
69
|
## Transaction Object
|
|
42
70
|
|
|
43
|
-
|
|
71
|
+
`beginTransaction()` returns an `IDatabaseTransaction` with the following properties:
|
|
44
72
|
|
|
45
73
|
| Property/Method | Type | Description |
|
|
46
74
|
| :--- | :--- | :--- |
|
|
47
|
-
| `connector` | `
|
|
75
|
+
| `connector` | `TRelationalConnector<Schema>` | A Drizzle connector bound to the transaction's dedicated connection |
|
|
48
76
|
| `isolationLevel` | `TIsolationLevel` | The isolation level of this transaction |
|
|
49
77
|
| `isActive` | `boolean` | Whether the transaction is still active (not yet committed/rolled back) |
|
|
50
|
-
| `commit()` | `Promise<void>` | Commit the
|
|
51
|
-
| `rollback()` | `Promise<void>` | Rollback the
|
|
78
|
+
| `commit()` | `Promise<void>` | Commit and release the connection. **Throws** if `COMMIT` fails, and destroys the connection rather than pooling it |
|
|
79
|
+
| `rollback()` | `Promise<void>` | Rollback and release the connection. **Throws** if `ROLLBACK` fails, and destroys the connection rather than pooling it |
|
|
52
80
|
|
|
53
|
-
Calling `commit()` or `rollback()` on an already-ended transaction throws an error.
|
|
81
|
+
Calling `commit()` or `rollback()` on an already-ended transaction throws an error, with one exception: `rollback()` after the transaction ended BY FAILURE is a silent no-op (see the warning above).
|
|
54
82
|
|
|
55
83
|
## Isolation Levels
|
|
56
84
|
|
|
57
|
-
|
|
85
|
+
IGNIS supports standard PostgreSQL isolation levels:
|
|
58
86
|
|
|
59
87
|
| Level | Description | Use Case |
|
|
60
88
|
|-------|-------------|----------|
|
|
@@ -63,17 +91,17 @@ Ignis supports standard PostgreSQL isolation levels:
|
|
|
63
91
|
| `SERIALIZABLE` | Strictest level. Emulates serial execution. | Financial transactions, critical data integrity. |
|
|
64
92
|
|
|
65
93
|
> [!NOTE]
|
|
66
|
-
>
|
|
94
|
+
> IGNIS only supports these three levels. The fourth SQL-standard level (uncommitted reads) is **not** accepted - PostgreSQL treats it as `READ COMMITTED` anyway, so IGNIS omits it to avoid confusion.
|
|
67
95
|
|
|
68
96
|
## Best Practices
|
|
69
97
|
|
|
70
|
-
1. **Always use `try...catch
|
|
98
|
+
1. **Always use `try...catch`, and nest the rollback**: `rollback()` throws when `ROLLBACK` fails, so a bare `await tx.rollback()` inside a `catch` would discard the error that sent you there. Wrap it in its own `try...catch`, log the rollback failure, and rethrow the original cause.
|
|
71
99
|
2. **Keep it short**: Long-running transactions hold database connections from the pool and can cause connection exhaustion.
|
|
72
100
|
3. **Pass explicit options**: When calling other services inside a transaction, ensure they accept and use the `transaction` option.
|
|
73
101
|
|
|
74
102
|
```typescript
|
|
75
103
|
// Service method supporting transactions
|
|
76
|
-
async createInitialOrder(opts: { userId: string; transaction?:
|
|
104
|
+
async createInitialOrder(opts: { userId: string; transaction?: IDatabaseTransaction }) {
|
|
77
105
|
return this.orderRepository.create({
|
|
78
106
|
data: { userId: opts.userId, status: 'PENDING' },
|
|
79
107
|
options: { transaction: opts.transaction } // Forward the transaction
|
|
@@ -99,12 +127,12 @@ export class OrderService extends BaseService {
|
|
|
99
127
|
async createOrderWithItems(opts: {
|
|
100
128
|
orderData: TOrderCreate;
|
|
101
129
|
items: TOrderItemCreate[];
|
|
102
|
-
transaction?:
|
|
130
|
+
transaction?: IDatabaseTransaction;
|
|
103
131
|
}) {
|
|
104
132
|
const { orderData, items, transaction } = opts;
|
|
105
133
|
|
|
106
134
|
// Create order
|
|
107
|
-
const order = await this._orderRepository.create({
|
|
135
|
+
const { data: order } = await this._orderRepository.create({
|
|
108
136
|
data: orderData,
|
|
109
137
|
options: { transaction },
|
|
110
138
|
});
|
|
@@ -138,7 +166,7 @@ export class OrderController extends BaseRestController {
|
|
|
138
166
|
|
|
139
167
|
@post({ configs: OrderRoutes.CREATE })
|
|
140
168
|
async createOrder(c: TRouteContext) {
|
|
141
|
-
const body = c.req.
|
|
169
|
+
const body = await c.req.json<{ order: TOrderCreate; items: TOrderItemCreate[] }>();
|
|
142
170
|
|
|
143
171
|
const tx = await this._orderRepository.beginTransaction({
|
|
144
172
|
isolationLevel: 'SERIALIZABLE',
|
|
@@ -154,7 +182,12 @@ export class OrderController extends BaseRestController {
|
|
|
154
182
|
await tx.commit();
|
|
155
183
|
return c.json(order, HTTP.ResultCodes.RS_2.Created);
|
|
156
184
|
} catch (err) {
|
|
157
|
-
|
|
185
|
+
try {
|
|
186
|
+
await tx.rollback();
|
|
187
|
+
} catch (rollbackError) {
|
|
188
|
+
this.logger.error('Rollback failed | %s', rollbackError);
|
|
189
|
+
}
|
|
190
|
+
|
|
158
191
|
throw err;
|
|
159
192
|
}
|
|
160
193
|
}
|
|
@@ -163,15 +196,18 @@ export class OrderController extends BaseRestController {
|
|
|
163
196
|
|
|
164
197
|
## How Transactions Work Internally
|
|
165
198
|
|
|
166
|
-
When you pass a `transaction` option to a repository method, the repository uses the transaction's `connector` (a Drizzle instance bound to the transaction's
|
|
199
|
+
When you pass a `transaction` option to a repository method, the repository uses the transaction's `connector` (a Drizzle instance bound to the transaction's dedicated connection) instead of the default datasource connector. This ensures all operations within the transaction use the same database connection and see a consistent view of the data.
|
|
167
200
|
|
|
168
201
|
```typescript
|
|
169
|
-
// Inside
|
|
170
|
-
protected resolveConnector(opts?: { transaction?:
|
|
171
|
-
if (opts?.transaction) {
|
|
172
|
-
return
|
|
202
|
+
// Inside PostgresBaseRepository (simplified)
|
|
203
|
+
protected resolveConnector(opts?: { transaction?: IDatabaseTransaction }) {
|
|
204
|
+
if (!opts?.transaction) {
|
|
205
|
+
return this.dataSource.connector;
|
|
173
206
|
}
|
|
174
|
-
|
|
207
|
+
|
|
208
|
+
// Throws if the transaction has already been committed/rolled back,
|
|
209
|
+
// or if it is not a postgres transaction.
|
|
210
|
+
return opts.transaction.connector;
|
|
175
211
|
}
|
|
176
212
|
```
|
|
177
213
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# REST Controllers
|
|
2
2
|
|
|
3
|
-
REST controllers handle incoming HTTP requests and return JSON responses -- they are your API endpoints. This is the default transport in
|
|
3
|
+
REST controllers handle incoming HTTP requests and return JSON responses -- they are your API endpoints. This is the default transport in IGNIS and covers the majority of use cases.
|
|
4
4
|
|
|
5
5
|
> **Deep Dive:** See [REST Controllers Reference](../../references/base/controllers.md) for the complete API.
|
|
6
6
|
|
|
@@ -9,8 +9,9 @@ REST controllers handle incoming HTTP requests and return JSON responses -- they
|
|
|
9
9
|
Extend `BaseRestController` and use decorators to define routes:
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import { BaseRestController, controller, get, jsonResponse,
|
|
12
|
+
import { BaseRestController, controller, get, jsonResponse, TRouteContext } from '@venizia/ignis';
|
|
13
13
|
import { HTTP } from '@venizia/ignis-helpers';
|
|
14
|
+
import { z } from '@hono/zod-openapi';
|
|
14
15
|
|
|
15
16
|
@controller({ path: '/users' })
|
|
16
17
|
export class UserController extends BaseRestController {
|
|
@@ -55,7 +56,7 @@ For decorator-based routes, you do not need to explicitly annotate the return ty
|
|
|
55
56
|
|
|
56
57
|
### HTTP Method Decorators
|
|
57
58
|
|
|
58
|
-
`
|
|
59
|
+
`IGNIS` provides a decorator for each common HTTP method:
|
|
59
60
|
|
|
60
61
|
- `@get(opts)`
|
|
61
62
|
- `@post(opts)`
|
|
@@ -132,7 +133,7 @@ export class MyItemsController extends BaseRestController {
|
|
|
132
133
|
|
|
133
134
|
## Manual Route Definition: An Alternative Approach
|
|
134
135
|
|
|
135
|
-
While decorators are the recommended approach for most use cases, `
|
|
136
|
+
While decorators are the recommended approach for most use cases, `IGNIS` also provides a manual way to define routes within the controller's `binding()` method.
|
|
136
137
|
|
|
137
138
|
### Decorator vs Manual: Quick Comparison
|
|
138
139
|
|
|
@@ -161,8 +162,9 @@ When using this method, you will override the `binding()` method in your control
|
|
|
161
162
|
Use this method for defining a single API endpoint with all its configurations and handler. It also benefits from type inference when used with `TRouteContext`.
|
|
162
163
|
|
|
163
164
|
```typescript
|
|
164
|
-
import { Authentication, jsonResponse,
|
|
165
|
+
import { Authentication, jsonResponse, TRouteContext } from '@venizia/ignis';
|
|
165
166
|
import { HTTP } from '@venizia/ignis-helpers';
|
|
167
|
+
import { z } from '@hono/zod-openapi';
|
|
166
168
|
|
|
167
169
|
// ... inside the binding() method
|
|
168
170
|
|
|
@@ -189,8 +191,9 @@ this.defineRoute({
|
|
|
189
191
|
This method offers a fluent API for defining routes, similar to `defineRoute`, but structured for chaining. It also benefits from `TRouteContext` for type safety.
|
|
190
192
|
|
|
191
193
|
```typescript
|
|
192
|
-
import { jsonResponse,
|
|
194
|
+
import { jsonResponse, TRouteContext } from '@venizia/ignis';
|
|
193
195
|
import { HTTP } from '@venizia/ignis-helpers';
|
|
196
|
+
import { z } from '@hono/zod-openapi';
|
|
194
197
|
|
|
195
198
|
// ... inside the binding() method
|
|
196
199
|
|
|
@@ -215,7 +218,7 @@ this.bindRoute({
|
|
|
215
218
|
|
|
216
219
|
## `ControllerFactory` for CRUD Operations
|
|
217
220
|
|
|
218
|
-
For standard CRUD (Create, Read, Update, Delete) operations, `
|
|
221
|
+
For standard CRUD (Create, Read, Update, Delete) operations, `IGNIS` provides a `ControllerFactory` that can generate a full-featured controller for any given entity. This significantly reduces boilerplate code.
|
|
219
222
|
|
|
220
223
|
```typescript
|
|
221
224
|
// src/controllers/configuration/configuration.controller.ts (Example from @examples/vert)
|
|
@@ -363,7 +366,7 @@ export const MainLayout: FC<PropsWithChildren<MainLayoutProps>> = ({ title, chil
|
|
|
363
366
|
};
|
|
364
367
|
```
|
|
365
368
|
|
|
366
|
-
> **Note:** JSX support in `
|
|
369
|
+
> **Note:** JSX support in `IGNIS` uses Hono's built-in JSX runtime. Make sure your `tsconfig.json` includes the JSX configuration (this is already set up in the framework's base configuration).
|
|
367
370
|
|
|
368
371
|
## Accessing Validated Request Data
|
|
369
372
|
|
|
@@ -454,7 +457,7 @@ Using `TRouteContext` provides a typed context object. By using `c.req.valid<T>(
|
|
|
454
457
|
- **References:**
|
|
455
458
|
- [BaseRestController API](/references/base/controllers) - Complete REST controller API reference
|
|
456
459
|
- [Middlewares](/references/base/middlewares) - Request interceptors
|
|
457
|
-
- [Swagger Component](/extensions/components/
|
|
460
|
+
- [Swagger Component](/extensions/components/api-reference) - Auto-generate API docs
|
|
458
461
|
- [Schema Utilities](/references/utilities/schema) - Request/response helpers
|
|
459
462
|
|
|
460
463
|
- **Tutorials:**
|