@venizia/ignis-docs 0.0.7 → 0.0.8-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/dist/mcp-server/common/paths.d.ts +4 -2
- package/dist/mcp-server/common/paths.d.ts.map +1 -1
- package/dist/mcp-server/common/paths.js +8 -6
- package/dist/mcp-server/common/paths.js.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/docs/get-document-content.tool.js +7 -7
- package/dist/mcp-server/tools/docs/get-document-metadata.tool.js +3 -3
- package/dist/mcp-server/tools/docs/get-package-overview.tool.d.ts +1 -1
- package/dist/mcp-server/tools/docs/get-package-overview.tool.js +1 -1
- package/package.json +1 -1
- package/wiki/best-practices/api-usage-examples.md +9 -9
- package/wiki/best-practices/architectural-patterns.md +19 -3
- package/wiki/best-practices/architecture-decisions.md +6 -6
- package/wiki/best-practices/code-style-standards/advanced-patterns.md +1 -1
- package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
- package/wiki/best-practices/code-style-standards/function-patterns.md +2 -2
- package/wiki/best-practices/code-style-standards/index.md +2 -2
- package/wiki/best-practices/code-style-standards/naming-conventions.md +1 -1
- package/wiki/best-practices/code-style-standards/route-definitions.md +4 -4
- package/wiki/best-practices/data-modeling.md +1 -1
- package/wiki/best-practices/deployment-strategies.md +1 -1
- package/wiki/best-practices/error-handling.md +2 -2
- 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/{references → extensions}/components/authentication/api.md +12 -20
- package/wiki/{references → extensions}/components/authentication/errors.md +1 -1
- package/wiki/{references → extensions}/components/authentication/index.md +5 -8
- package/wiki/{references → extensions}/components/authentication/usage.md +20 -36
- package/wiki/{references → extensions}/components/authorization/api.md +62 -13
- package/wiki/{references → extensions}/components/authorization/errors.md +12 -7
- package/wiki/{references → extensions}/components/authorization/index.md +93 -6
- package/wiki/{references → extensions}/components/authorization/usage.md +42 -4
- package/wiki/{references → extensions}/components/health-check.md +5 -4
- package/wiki/{references → extensions}/components/index.md +2 -0
- package/wiki/{references → extensions}/components/mail/index.md +1 -1
- package/wiki/{references → extensions}/components/request-tracker.md +1 -1
- package/wiki/{references → extensions}/components/socket-io/api.md +2 -2
- package/wiki/{references → extensions}/components/socket-io/errors.md +2 -0
- package/wiki/{references → extensions}/components/socket-io/index.md +24 -20
- package/wiki/{references → extensions}/components/socket-io/usage.md +2 -2
- package/wiki/{references → extensions}/components/static-asset/api.md +14 -15
- package/wiki/{references → extensions}/components/static-asset/errors.md +3 -1
- package/wiki/{references → extensions}/components/static-asset/index.md +158 -89
- package/wiki/{references → extensions}/components/static-asset/usage.md +8 -5
- package/wiki/{references → extensions}/components/swagger.md +3 -3
- package/wiki/{references → extensions}/components/template/index.md +4 -4
- package/wiki/{references → extensions}/components/template/setup-page.md +1 -1
- package/wiki/{references → extensions}/components/template/single-page.md +1 -1
- package/wiki/{references → extensions}/components/websocket/api.md +7 -6
- package/wiki/{references → extensions}/components/websocket/errors.md +17 -3
- package/wiki/{references → extensions}/components/websocket/index.md +17 -11
- package/wiki/{references → extensions}/components/websocket/usage.md +2 -2
- package/wiki/{references → extensions}/helpers/crypto/index.md +1 -1
- package/wiki/{references → extensions}/helpers/env/index.md +9 -5
- package/wiki/{references → extensions}/helpers/error/index.md +2 -7
- package/wiki/{references → extensions}/helpers/index.md +18 -6
- package/wiki/{references → extensions}/helpers/kafka/admin.md +13 -1
- package/wiki/{references → extensions}/helpers/kafka/consumer.md +28 -28
- package/wiki/{references → extensions}/helpers/kafka/examples.md +19 -19
- package/wiki/{references → extensions}/helpers/kafka/index.md +51 -48
- package/wiki/{references → extensions}/helpers/kafka/producer.md +18 -18
- package/wiki/{references → extensions}/helpers/kafka/schema-registry.md +25 -25
- package/wiki/{references → extensions}/helpers/logger/index.md +2 -2
- package/wiki/{references → extensions}/helpers/queue/index.md +400 -4
- package/wiki/{references → extensions}/helpers/storage/api.md +170 -10
- package/wiki/{references → extensions}/helpers/storage/index.md +44 -8
- package/wiki/{references → extensions}/helpers/template/index.md +1 -1
- package/wiki/{references → extensions}/helpers/testing/index.md +4 -4
- package/wiki/{references → extensions}/helpers/types/index.md +63 -16
- package/wiki/{references → extensions}/helpers/websocket/index.md +1 -1
- package/wiki/extensions/index.md +48 -0
- package/wiki/guides/core-concepts/application/bootstrapping.md +55 -37
- package/wiki/guides/core-concepts/application/index.md +95 -35
- package/wiki/guides/core-concepts/components-guide.md +23 -19
- package/wiki/guides/core-concepts/components.md +34 -10
- package/wiki/guides/core-concepts/dependency-injection.md +99 -34
- package/wiki/guides/core-concepts/grpc-controllers.md +295 -0
- package/wiki/guides/core-concepts/persistent/datasources.md +27 -8
- package/wiki/guides/core-concepts/persistent/models.md +43 -1
- package/wiki/guides/core-concepts/persistent/repositories.md +75 -8
- package/wiki/guides/core-concepts/persistent/transactions.md +38 -8
- package/wiki/guides/core-concepts/{controllers.md → rest-controllers.md} +30 -33
- package/wiki/guides/core-concepts/services.md +19 -5
- package/wiki/guides/get-started/5-minute-quickstart.md +6 -7
- package/wiki/guides/get-started/philosophy.md +1 -1
- package/wiki/guides/index.md +2 -2
- package/wiki/guides/reference/glossary.md +7 -7
- package/wiki/guides/reference/mcp-docs-server.md +1 -1
- package/wiki/guides/tutorials/building-a-crud-api.md +2 -2
- package/wiki/guides/tutorials/complete-installation.md +17 -14
- package/wiki/guides/tutorials/ecommerce-api.md +18 -18
- package/wiki/guides/tutorials/realtime-chat.md +8 -8
- package/wiki/guides/tutorials/testing.md +2 -2
- package/wiki/index.md +4 -3
- package/wiki/references/base/application.md +341 -21
- package/wiki/references/base/bootstrapping.md +43 -13
- package/wiki/references/base/components.md +259 -8
- package/wiki/references/base/controllers.md +556 -253
- package/wiki/references/base/datasources.md +159 -79
- package/wiki/references/base/dependency-injection.md +299 -48
- package/wiki/references/base/filter-system/application-usage.md +18 -2
- package/wiki/references/base/filter-system/array-operators.md +14 -6
- package/wiki/references/base/filter-system/comparison-operators.md +9 -3
- package/wiki/references/base/filter-system/default-filter.md +28 -3
- package/wiki/references/base/filter-system/fields-order-pagination.md +17 -13
- package/wiki/references/base/filter-system/index.md +169 -11
- package/wiki/references/base/filter-system/json-filtering.md +51 -18
- package/wiki/references/base/filter-system/list-operators.md +4 -3
- package/wiki/references/base/filter-system/logical-operators.md +7 -2
- package/wiki/references/base/filter-system/null-operators.md +50 -0
- package/wiki/references/base/filter-system/quick-reference.md +82 -243
- package/wiki/references/base/filter-system/range-operators.md +7 -1
- package/wiki/references/base/filter-system/tips.md +34 -7
- package/wiki/references/base/filter-system/use-cases.md +6 -5
- package/wiki/references/base/grpc-controllers.md +984 -0
- package/wiki/references/base/index.md +32 -24
- package/wiki/references/base/middleware.md +347 -0
- package/wiki/references/base/models.md +390 -46
- package/wiki/references/base/providers.md +14 -14
- package/wiki/references/base/repositories/advanced.md +84 -69
- package/wiki/references/base/repositories/index.md +447 -12
- package/wiki/references/base/repositories/mixins.md +103 -98
- package/wiki/references/base/repositories/relations.md +129 -45
- package/wiki/references/base/repositories/soft-deletable.md +104 -23
- package/wiki/references/base/services.md +94 -14
- package/wiki/references/index.md +12 -10
- package/wiki/references/quick-reference.md +98 -65
- package/wiki/references/utilities/crypto.md +21 -4
- package/wiki/references/utilities/date.md +25 -7
- package/wiki/references/utilities/index.md +26 -24
- package/wiki/references/utilities/jsx.md +54 -54
- package/wiki/references/utilities/module.md +8 -6
- package/wiki/references/utilities/parse.md +16 -9
- package/wiki/references/utilities/performance.md +22 -7
- package/wiki/references/utilities/promise.md +19 -16
- package/wiki/references/utilities/request.md +48 -26
- package/wiki/references/utilities/schema.md +69 -6
- package/wiki/references/utilities/statuses.md +131 -140
- /package/wiki/{references → extensions}/components/mail/api.md +0 -0
- /package/wiki/{references → extensions}/components/mail/errors.md +0 -0
- /package/wiki/{references → extensions}/components/mail/usage.md +0 -0
- /package/wiki/{references → extensions}/components/template/api-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/errors-page.md +0 -0
- /package/wiki/{references → extensions}/components/template/usage-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/cron/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/inversion/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/network/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/redis/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/socket-io/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/template/single-page.md +0 -0
- /package/wiki/{references → extensions}/helpers/uid/index.md +0 -0
- /package/wiki/{references → extensions}/helpers/websocket/api.md +0 -0
- /package/wiki/{references → extensions}/helpers/worker-thread/index.md +0 -0
- /package/wiki/{references → extensions}/src-details/mcp-server.md +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Quick Reference Card
|
|
3
3
|
description: Single-page cheat sheet for IGNIS framework
|
|
4
|
-
lastUpdated: 2026-
|
|
4
|
+
lastUpdated: 2026-03-15
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Quick Reference Card
|
|
@@ -33,25 +33,53 @@ await app.start();
|
|
|
33
33
|
- `get<T>(key)` - Resolve from DI container
|
|
34
34
|
- `mountControllers()` - Register controllers
|
|
35
35
|
|
|
36
|
-
###
|
|
36
|
+
### BaseRestController
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import {
|
|
39
|
+
import { BaseRestController, controller, get } from '@venizia/ignis';
|
|
40
40
|
|
|
41
41
|
@controller({ path: '/users' })
|
|
42
|
-
class UserController extends
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
class UserController extends BaseRestController {
|
|
43
|
+
constructor() {
|
|
44
|
+
super({ scope: UserController.name, path: '/users' });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override binding() {}
|
|
48
|
+
|
|
49
|
+
@get({ configs: { path: '/:id', responses: { 200: { description: 'User' } } } })
|
|
50
|
+
getUser(c: Context) {
|
|
51
|
+
const id = c.req.param('id');
|
|
52
|
+
return c.json({ id, name: 'John' });
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
```
|
|
49
56
|
|
|
50
57
|
**Key Properties:**
|
|
51
|
-
- `this.
|
|
52
|
-
- `this.
|
|
58
|
+
- `this.router` - OpenAPIHono instance
|
|
59
|
+
- `this.path` - Controller base path
|
|
53
60
|
- `this.logger` - Scoped logger
|
|
54
61
|
|
|
62
|
+
### BaseGrpcController
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { BaseGrpcController, controller, unary, ControllerTransports } from '@venizia/ignis';
|
|
66
|
+
import { GreeterService } from '../gen/greeter_connect';
|
|
67
|
+
|
|
68
|
+
@controller({ path: '/grpc', transport: ControllerTransports.GRPC, service: GreeterService })
|
|
69
|
+
class GreeterController extends BaseGrpcController {
|
|
70
|
+
constructor() {
|
|
71
|
+
super({ scope: GreeterController.name, path: '/grpc' });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override binding() {}
|
|
75
|
+
|
|
76
|
+
@unary({ configs: { name: 'sayHello' } })
|
|
77
|
+
async sayHello(request: SayHelloRequest) {
|
|
78
|
+
return { message: `Hello, ${request.name}!` };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
55
83
|
### BaseService
|
|
56
84
|
|
|
57
85
|
```typescript
|
|
@@ -133,39 +161,41 @@ class User extends BaseEntity {
|
|
|
133
161
|
| `@patch()` | PATCH | `@patch({ configs: { path: '/:id' } })` |
|
|
134
162
|
| `@del()` | DELETE | `@del({ configs: { path: '/:id' } })` |
|
|
135
163
|
|
|
136
|
-
###
|
|
164
|
+
### RPC Method Decorators (gRPC)
|
|
137
165
|
|
|
138
|
-
| Decorator |
|
|
166
|
+
| Decorator | RPC Type | Example |
|
|
139
167
|
|-----------|----------|---------|
|
|
140
|
-
| `@
|
|
141
|
-
| `@
|
|
142
|
-
| `@
|
|
143
|
-
| `@
|
|
168
|
+
| `@rpc()` | Generic | `@rpc({ configs: { name: 'myMethod', method: 'unary' } })` |
|
|
169
|
+
| `@unary()` | Unary | `@unary({ configs: { name: 'sayHello' } })` |
|
|
170
|
+
| `@serverStream()` | Server streaming | `@serverStream({ configs: { name: 'listItems' } })` |
|
|
171
|
+
| `@clientStream()` | Client streaming | `@clientStream({ configs: { name: 'uploadData' } })` |
|
|
172
|
+
| `@bidiStream()` | Bidirectional | `@bidiStream({ configs: { name: 'chat' } })` |
|
|
144
173
|
|
|
145
|
-
### Example
|
|
174
|
+
### REST Example
|
|
146
175
|
|
|
147
176
|
```typescript
|
|
148
177
|
@controller({ path: '/users' })
|
|
149
|
-
class UserController extends
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
@body() data: CreateUserDto,
|
|
153
|
-
@header('authorization') token: string
|
|
178
|
+
class UserController extends BaseRestController {
|
|
179
|
+
constructor(
|
|
180
|
+
@inject({ key: 'services.UserService' }) private userService: UserService,
|
|
154
181
|
) {
|
|
155
|
-
|
|
182
|
+
super({ scope: UserController.name, path: '/users' });
|
|
156
183
|
}
|
|
157
184
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
185
|
+
override binding() {}
|
|
186
|
+
|
|
187
|
+
@post({ configs: { path: '/', responses: { 201: { description: 'Created' } } } })
|
|
188
|
+
async createUser(c: Context) {
|
|
189
|
+
const data = await c.req.json();
|
|
190
|
+
const result = await this.userService.create(data);
|
|
191
|
+
return c.json(result, 201);
|
|
164
192
|
}
|
|
165
193
|
|
|
166
|
-
@get({ configs: { path: '/:id' } })
|
|
167
|
-
async getUser(
|
|
168
|
-
|
|
194
|
+
@get({ configs: { path: '/:id', responses: { 200: { description: 'User' } } } })
|
|
195
|
+
async getUser(c: Context) {
|
|
196
|
+
const id = c.req.param('id');
|
|
197
|
+
const result = await this.userService.findById(id);
|
|
198
|
+
return c.json(result);
|
|
169
199
|
}
|
|
170
200
|
}
|
|
171
201
|
```
|
|
@@ -309,15 +339,13 @@ class MyService extends BaseService {
|
|
|
309
339
|
```typescript
|
|
310
340
|
import { inject } from '@venizia/ignis';
|
|
311
341
|
|
|
312
|
-
|
|
313
|
-
class UserController extends BaseController {
|
|
342
|
+
class UserController extends BaseRestController {
|
|
314
343
|
constructor(
|
|
315
344
|
@inject({ key: 'services.UserService' })
|
|
316
|
-
private userService: UserService
|
|
345
|
+
private userService: UserService,
|
|
317
346
|
) {
|
|
318
|
-
super();
|
|
347
|
+
super({ scope: UserController.name, path: '/users' });
|
|
319
348
|
}
|
|
320
|
-
}
|
|
321
349
|
```
|
|
322
350
|
|
|
323
351
|
### Manual Resolution
|
|
@@ -336,21 +364,24 @@ import {
|
|
|
336
364
|
// Application
|
|
337
365
|
BaseApplication,
|
|
338
366
|
|
|
339
|
-
// Controllers
|
|
340
|
-
|
|
367
|
+
// REST Controllers
|
|
368
|
+
BaseRestController,
|
|
341
369
|
controller,
|
|
342
370
|
|
|
343
|
-
//
|
|
344
|
-
|
|
371
|
+
// gRPC Controllers
|
|
372
|
+
BaseGrpcController,
|
|
373
|
+
ControllerTransports,
|
|
374
|
+
|
|
375
|
+
// REST Route Decorators
|
|
376
|
+
get, post, put, patch, del, api,
|
|
345
377
|
|
|
346
|
-
//
|
|
347
|
-
|
|
378
|
+
// gRPC Route Decorators
|
|
379
|
+
rpc, unary, serverStream, clientStream, bidiStream,
|
|
348
380
|
|
|
349
381
|
// Services
|
|
350
382
|
BaseService,
|
|
351
383
|
|
|
352
384
|
// Repositories
|
|
353
|
-
BaseRepository,
|
|
354
385
|
DefaultCRUDRepository,
|
|
355
386
|
|
|
356
387
|
// Models
|
|
@@ -423,8 +454,9 @@ import { z } from '@hono/zod-openapi';
|
|
|
423
454
|
}),
|
|
424
455
|
},
|
|
425
456
|
})
|
|
426
|
-
|
|
427
|
-
|
|
457
|
+
getUser(c: Context) {
|
|
458
|
+
const id = c.req.param('id');
|
|
459
|
+
return c.json({ id, name: 'John', email: 'john@example.com' });
|
|
428
460
|
}
|
|
429
461
|
```
|
|
430
462
|
|
|
@@ -441,8 +473,8 @@ import { htmlResponse } from '@venizia/ignis';
|
|
|
441
473
|
}),
|
|
442
474
|
},
|
|
443
475
|
})
|
|
444
|
-
|
|
445
|
-
return
|
|
476
|
+
getDashboard(c: Context) {
|
|
477
|
+
return c.html(<DashboardPage />);
|
|
446
478
|
}
|
|
447
479
|
```
|
|
448
480
|
|
|
@@ -552,26 +584,28 @@ const apiKey = EnvHelper.getRequired('API_KEY');
|
|
|
552
584
|
```typescript
|
|
553
585
|
// Controller
|
|
554
586
|
@controller({ path: '/users' })
|
|
555
|
-
class UserController extends
|
|
587
|
+
class UserController extends BaseRestController {
|
|
556
588
|
constructor(
|
|
557
589
|
@inject({ key: 'services.UserService' })
|
|
558
|
-
private userService: UserService
|
|
590
|
+
private userService: UserService,
|
|
559
591
|
) {
|
|
560
|
-
super();
|
|
592
|
+
super({ scope: UserController.name, path: '/users' });
|
|
561
593
|
}
|
|
562
594
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
595
|
+
override binding() {}
|
|
596
|
+
|
|
597
|
+
@post({ configs: { path: '/', responses: { 201: { description: 'Created' } } } })
|
|
598
|
+
async createUser(c: Context) {
|
|
599
|
+
const data = await c.req.json();
|
|
600
|
+
return c.json(await this.userService.create(data), 201);
|
|
566
601
|
}
|
|
567
602
|
}
|
|
568
603
|
|
|
569
604
|
// Service
|
|
570
|
-
@injectable()
|
|
571
605
|
class UserService extends BaseService {
|
|
572
606
|
constructor(
|
|
573
607
|
@inject({ key: 'repositories.UserRepository' })
|
|
574
|
-
private userRepo: UserRepository
|
|
608
|
+
private userRepo: UserRepository,
|
|
575
609
|
) {
|
|
576
610
|
super({ scope: UserService.name });
|
|
577
611
|
}
|
|
@@ -581,19 +615,18 @@ class UserService extends BaseService {
|
|
|
581
615
|
const hashedPassword = await hash({ value: data.password });
|
|
582
616
|
|
|
583
617
|
return this.userRepo.create({
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
618
|
+
data: {
|
|
619
|
+
...data,
|
|
620
|
+
password: hashedPassword,
|
|
621
|
+
},
|
|
587
622
|
});
|
|
588
623
|
}
|
|
589
624
|
}
|
|
590
625
|
|
|
591
626
|
// Repository
|
|
592
|
-
@
|
|
593
|
-
class UserRepository extends DefaultCRUDRepository<User> {
|
|
594
|
-
|
|
595
|
-
super(User);
|
|
596
|
-
}
|
|
627
|
+
@repository({ model: User, dataSource: PostgresDataSource })
|
|
628
|
+
class UserRepository extends DefaultCRUDRepository<typeof User.schema> {
|
|
629
|
+
// DataSource auto-injected from @repository decorator
|
|
597
630
|
}
|
|
598
631
|
```
|
|
599
632
|
|
|
@@ -602,8 +635,8 @@ class UserRepository extends DefaultCRUDRepository<User> {
|
|
|
602
635
|
|
|
603
636
|
- **Full Documentation:**
|
|
604
637
|
- [Base Abstractions](./base/) - Complete API reference
|
|
605
|
-
- [Components](
|
|
606
|
-
- [Helpers](
|
|
638
|
+
- [Components](/extensions/components/) - Pre-built features
|
|
639
|
+
- [Helpers](/extensions/helpers/) - Utility helpers
|
|
607
640
|
- [Utilities](./utilities/) - Pure functions
|
|
608
641
|
|
|
609
642
|
- **Guides:**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Crypto Utility
|
|
2
2
|
|
|
3
|
-
The Crypto utility provides simple, stateless functions for cryptographic hashing.
|
|
3
|
+
The Crypto utility provides simple, stateless functions for cryptographic hashing using Node.js's built-in `node:crypto` module.
|
|
4
4
|
|
|
5
5
|
## `hash`
|
|
6
6
|
|
|
@@ -10,9 +10,15 @@ The `hash` function allows you to create a hash of a string using either `SHA256
|
|
|
10
10
|
|
|
11
11
|
- `text` (string): The input string to hash.
|
|
12
12
|
- `options` (object):
|
|
13
|
-
- `algorithm` ('SHA256' | 'MD5'): The hashing algorithm to use.
|
|
14
|
-
- `secret` (string, optional): The secret key for HMAC-SHA256.
|
|
15
|
-
- `outputType` (BinaryToTextEncoding): The output encoding (e.g., 'hex'
|
|
13
|
+
- `algorithm` (`'SHA256'` | `'MD5'`): The hashing algorithm to use.
|
|
14
|
+
- `secret` (string, optional): The secret key for HMAC-SHA256. If `algorithm` is `'SHA256'` and no `secret` is provided, the original text is returned unchanged.
|
|
15
|
+
- `outputType` (`BinaryToTextEncoding`): The output encoding (e.g., `'hex'`, `'base64'`).
|
|
16
|
+
|
|
17
|
+
### Behavior
|
|
18
|
+
|
|
19
|
+
- **SHA256**: Creates an HMAC using the provided `secret`. Returns the original text if no secret is given.
|
|
20
|
+
- **MD5**: Creates a standard hash digest (no secret needed).
|
|
21
|
+
- **Other algorithms**: Returns the original text unchanged.
|
|
16
22
|
|
|
17
23
|
### Examples
|
|
18
24
|
|
|
@@ -37,3 +43,14 @@ const sha256Hash = hash('some text', {
|
|
|
37
43
|
});
|
|
38
44
|
// => 'b8a1c3f2... (64-character hex string)'
|
|
39
45
|
```
|
|
46
|
+
|
|
47
|
+
**Base64 output**
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { hash } from '@venizia/ignis-helpers';
|
|
51
|
+
|
|
52
|
+
const base64Hash = hash('some text', {
|
|
53
|
+
algorithm: 'MD5',
|
|
54
|
+
outputType: 'base64',
|
|
55
|
+
});
|
|
56
|
+
```
|
|
@@ -6,6 +6,8 @@ The Date utility provides a set of functions for date and time manipulation, bui
|
|
|
6
6
|
|
|
7
7
|
The `dayjs` object is re-exported, so you can use it directly for any date and time operations. It is pre-configured with the following plugins: `CustomParseFormat`, `UTC`, `Timezone`, `Weekday`, and `IsoWeek`.
|
|
8
8
|
|
|
9
|
+
The default timezone is set to `Asia/Ho_Chi_Minh` and can be overridden via the `APP_ENV_APPLICATION_TIMEZONE` environment variable.
|
|
10
|
+
|
|
9
11
|
```typescript
|
|
10
12
|
import { dayjs } from '@venizia/ignis-helpers';
|
|
11
13
|
|
|
@@ -32,21 +34,30 @@ async function myAsyncFunction() {
|
|
|
32
34
|
|
|
33
35
|
## Weekday Functions
|
|
34
36
|
|
|
35
|
-
- **`isWeekday(date)`**: Checks if a given date is a weekday (Monday to Friday).
|
|
36
|
-
- **`getPreviousWeekday(opts)`**: Returns the previous weekday from a given date.
|
|
37
|
-
- **`getNextWeekday(opts)`**: Returns the next weekday from a given date.
|
|
37
|
+
- **`isWeekday(date)`**: Checks if a given date is a weekday (Monday to Friday). Accepts a `string` or `dayjs.Dayjs` instance.
|
|
38
|
+
- **`getPreviousWeekday(opts?)`**: Returns the previous weekday from a given date. If no date is provided, defaults to today.
|
|
39
|
+
- **`getNextWeekday(opts?)`**: Returns the next weekday from a given date. If no date is provided, defaults to today.
|
|
38
40
|
|
|
39
41
|
```typescript
|
|
40
|
-
import { isWeekday, getPreviousWeekday } from '@venizia/ignis-helpers';
|
|
42
|
+
import { isWeekday, getPreviousWeekday, getNextWeekday } from '@venizia/ignis-helpers';
|
|
41
43
|
|
|
42
|
-
const isTodayWeekday = isWeekday(
|
|
44
|
+
const isTodayWeekday = isWeekday('2026-03-15');
|
|
43
45
|
|
|
44
46
|
const lastBusinessDay = getPreviousWeekday();
|
|
47
|
+
const nextBusinessDay = getNextWeekday({ date: '2026-03-13' });
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
## `getDateTz`
|
|
48
51
|
|
|
49
|
-
The `getDateTz` function allows you to get a `dayjs` object in a specific timezone, with an optional offset.
|
|
52
|
+
The `getDateTz` function allows you to get a `dayjs` object in a specific timezone, with an optional hour offset.
|
|
53
|
+
|
|
54
|
+
### `getDateTz(opts)`
|
|
55
|
+
|
|
56
|
+
- `opts` (object):
|
|
57
|
+
- `date` (string): The date string to parse.
|
|
58
|
+
- `timezone` (string): The IANA timezone name.
|
|
59
|
+
- `useClientTz` (boolean, optional): Whether to keep the client's timezone. Defaults to `false`.
|
|
60
|
+
- `timeOffset` (number, optional): Number of hours to add to the result. Defaults to `0`.
|
|
50
61
|
|
|
51
62
|
```typescript
|
|
52
63
|
import { getDateTz } from '@venizia/ignis-helpers';
|
|
@@ -55,11 +66,18 @@ const tokyoTime = getDateTz({
|
|
|
55
66
|
date: '2023-10-27T10:00:00Z',
|
|
56
67
|
timezone: 'Asia/Tokyo',
|
|
57
68
|
});
|
|
69
|
+
|
|
70
|
+
// With hour offset
|
|
71
|
+
const offsetTime = getDateTz({
|
|
72
|
+
date: '2023-10-27T10:00:00Z',
|
|
73
|
+
timezone: 'Asia/Tokyo',
|
|
74
|
+
timeOffset: 2, // Add 2 hours
|
|
75
|
+
});
|
|
58
76
|
```
|
|
59
77
|
|
|
60
78
|
## `hrTime`
|
|
61
79
|
|
|
62
|
-
The `hrTime` function returns a high-resolution time measurement in seconds
|
|
80
|
+
The `hrTime` function returns a high-resolution time measurement in seconds using `process.hrtime()`, useful for performance benchmarking. The result is rounded to 9 decimal places.
|
|
63
81
|
|
|
64
82
|
```typescript
|
|
65
83
|
import { hrTime } from '@venizia/ignis-helpers';
|
|
@@ -4,26 +4,26 @@ Pure, standalone functions providing common, reusable logic for the Ignis framew
|
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
7
|
-
| Utility | Purpose | Key Functions |
|
|
8
|
-
|
|
9
|
-
| **Crypto** | Cryptographic
|
|
10
|
-
| **Date** | Date/time manipulation | `
|
|
11
|
-
| **JSX** | HTML/JSX responses | `htmlContent()`, `htmlResponse()` |
|
|
12
|
-
| **Module** | Module
|
|
13
|
-
| **Parse** | Data type conversion | `toBoolean()`, `
|
|
14
|
-
| **Performance** | Execution timing | `
|
|
15
|
-
| **Promise** | Promise helpers | `
|
|
16
|
-
| **Request** | HTTP utilities | `
|
|
17
|
-
| **Schema** | Zod schema helpers | `jsonContent()`, `jsonResponse()` |
|
|
18
|
-
| **Statuses** | Status code constants | `Statuses`, `UserStatuses`, `
|
|
7
|
+
| Utility | Package | Purpose | Key Functions |
|
|
8
|
+
|---------|---------|---------|---------------|
|
|
9
|
+
| **Crypto** | `ignis-helpers` | Cryptographic hashing | `hash()` |
|
|
10
|
+
| **Date** | `ignis-helpers` | Date/time manipulation | `dayjs`, `sleep()`, `isWeekday()`, `getDateTz()`, `hrTime()` |
|
|
11
|
+
| **JSX** | `ignis` | HTML/JSX responses | `htmlContent()`, `htmlResponse()` |
|
|
12
|
+
| **Module** | `ignis-helpers` | Module validation | `validateModule()` |
|
|
13
|
+
| **Parse** | `ignis-helpers` | Data type conversion | `int()`, `float()`, `toBoolean()`, `toCamel()`, `getNumberValue()` |
|
|
14
|
+
| **Performance** | `ignis-helpers` | Execution timing | `executeWithPerformanceMeasure()`, `getPerformanceCheckpoint()` |
|
|
15
|
+
| **Promise** | `ignis-helpers` | Promise helpers | `executePromiseWithLimit()`, `isPromiseLike()`, `getDeepProperty()` |
|
|
16
|
+
| **Request** | `ignis-helpers` | HTTP utilities | `parseMultipartBody()`, `sanitizeFilename()`, `createContentDispositionHeader()` |
|
|
17
|
+
| **Schema** | `ignis` | Zod schema helpers | `jsonContent()`, `jsonResponse()`, `requiredString()`, `idParamsSchema()` |
|
|
18
|
+
| **Statuses** | `ignis` | Status code constants | `Statuses`, `CommonStatuses`, `UserStatuses`, `RoleStatuses` |
|
|
19
19
|
|
|
20
20
|
## What's in This Section
|
|
21
21
|
|
|
22
22
|
### Data Processing
|
|
23
23
|
|
|
24
|
-
- [**Crypto**](./crypto.md) - Simple, stateless cryptographic functions for hashing
|
|
25
|
-
- [**Parse**](./parse.md) - Functions for parsing and converting data types safely
|
|
26
|
-
- [**Schema**](./schema.md) - Helpers for creating
|
|
24
|
+
- [**Crypto**](./crypto.md) - Simple, stateless cryptographic functions for hashing (SHA256 HMAC, MD5)
|
|
25
|
+
- [**Parse**](./parse.md) - Functions for parsing and converting data types safely (integers, floats, booleans, camelCase, locale-aware numbers, array-to-map)
|
|
26
|
+
- [**Schema**](./schema.md) - Helpers for creating Zod schemas for OpenAPI request/response validation
|
|
27
27
|
- [**Statuses**](./statuses.md) - Standardized status code constants for entity lifecycle management
|
|
28
28
|
|
|
29
29
|
### Time & Performance
|
|
@@ -34,30 +34,32 @@ Pure, standalone functions providing common, reusable logic for the Ignis framew
|
|
|
34
34
|
### Async & HTTP
|
|
35
35
|
|
|
36
36
|
- [**JSX**](./jsx.md) - HTML and JSX response utilities for server-side rendering and OpenAPI documentation
|
|
37
|
-
- [**Promise**](./promise.md) - Helper functions for working with Promises including
|
|
37
|
+
- [**Promise**](./promise.md) - Helper functions for working with Promises including concurrency limiting and value transformation
|
|
38
38
|
- [**Request**](./request.md) - HTTP request utilities for parsing multipart form data and creating secure Content-Disposition headers
|
|
39
39
|
|
|
40
40
|
### Runtime
|
|
41
41
|
|
|
42
|
-
- [**Module**](./module.md) - Utility for
|
|
42
|
+
- [**Module**](./module.md) - Utility for validating that required Node.js modules are installed at runtime
|
|
43
43
|
|
|
44
44
|
## Usage Pattern
|
|
45
45
|
|
|
46
46
|
Utilities are imported from `@venizia/ignis` (schema, JSX, and status helpers) or `@venizia/ignis-helpers` (runtime utilities):
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
import { jsonContent, jsonResponse, htmlResponse, Statuses } from '@venizia/ignis';
|
|
50
|
-
import { hash,
|
|
49
|
+
import { jsonContent, jsonResponse, htmlResponse, requiredString, Statuses } from '@venizia/ignis';
|
|
50
|
+
import { hash, dayjs, sleep, int, float, toBoolean, getNumberValue } from '@venizia/ignis-helpers';
|
|
51
51
|
|
|
52
52
|
// Crypto
|
|
53
|
-
const
|
|
54
|
-
const isMatch = await compare({ value: 'password123', hashed });
|
|
53
|
+
const md5Hash = hash('some text', { algorithm: 'MD5', outputType: 'hex' });
|
|
55
54
|
|
|
56
55
|
// Date
|
|
57
|
-
const
|
|
56
|
+
const now = dayjs();
|
|
57
|
+
await sleep(1000);
|
|
58
58
|
|
|
59
59
|
// Parse
|
|
60
|
-
const
|
|
60
|
+
const myInt = int('1,000'); // 1000
|
|
61
|
+
const myFloat = float('1,234.567', 2); // 1234.57
|
|
62
|
+
const myBool = toBoolean('true'); // true
|
|
61
63
|
|
|
62
64
|
// Schema (for OpenAPI JSON routes)
|
|
63
65
|
const responseSchema = jsonResponse({
|
|
@@ -77,4 +79,4 @@ if (Statuses.isCompleted(order.status)) {
|
|
|
77
79
|
}
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
> **Related:** [Helpers Reference](
|
|
82
|
+
> **Related:** [Helpers Reference](/extensions/helpers/) | [Core Concepts Guide](../../guides/core-concepts/application/)
|