@venizia/ignis-helpers 0.0.1-2 → 0.0.1-4
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/LICENSE.md +102 -0
- package/README.md +43 -0
- package/dist/common/constants/app.d.ts +1 -1
- package/dist/common/constants/app.js +8 -8
- package/dist/common/constants/http.d.ts +1 -1
- package/dist/common/constants/http.js +13 -13
- package/dist/common/constants/index.d.ts +3 -3
- package/dist/common/constants/mime.d.ts +1 -1
- package/dist/common/constants/mime.js +4 -4
- package/dist/common/index.d.ts +2 -2
- package/dist/common/types.d.ts +13 -13
- package/dist/common/types.js +2 -2
- package/dist/helpers/base.d.ts +1 -1
- package/dist/helpers/base.js +3 -3
- package/dist/helpers/cron/cron.helper.d.ts +2 -2
- package/dist/helpers/cron/cron.helper.js +2 -2
- package/dist/helpers/cron/index.d.ts +1 -1
- package/dist/helpers/crypto/algorithms/aes.algorithm.d.ts +3 -3
- package/dist/helpers/crypto/algorithms/aes.algorithm.js +10 -10
- package/dist/helpers/crypto/algorithms/base.algorithm.d.ts +2 -2
- package/dist/helpers/crypto/algorithms/base.algorithm.js +1 -1
- package/dist/helpers/crypto/algorithms/index.d.ts +3 -3
- package/dist/helpers/crypto/algorithms/rsa.algorithm.d.ts +3 -3
- package/dist/helpers/crypto/algorithms/rsa.algorithm.js +10 -10
- package/dist/helpers/crypto/common/index.d.ts +2 -2
- package/dist/helpers/crypto/index.d.ts +2 -2
- package/dist/helpers/env/app-env.d.ts +1 -1
- package/dist/helpers/env/app-env.js +9 -9
- package/dist/helpers/env/index.d.ts +2 -2
- package/dist/helpers/error/app-error.d.ts +1 -1
- package/dist/helpers/error/index.d.ts +2 -2
- package/dist/helpers/error/types.d.ts +1 -1
- package/dist/helpers/error/types.js +5 -5
- package/dist/helpers/index.d.ts +14 -14
- package/dist/helpers/inversion/common/index.d.ts +2 -2
- package/dist/helpers/inversion/common/keys.js +6 -6
- package/dist/helpers/inversion/common/types.d.ts +4 -4
- package/dist/helpers/inversion/container.d.ts +2 -2
- package/dist/helpers/inversion/index.d.ts +4 -4
- package/dist/helpers/inversion/registry.d.ts +2 -2
- package/dist/helpers/logger/application-logger.d.ts +2 -2
- package/dist/helpers/logger/application-logger.js +8 -8
- package/dist/helpers/logger/default-logger.d.ts +3 -3
- package/dist/helpers/logger/default-logger.js +23 -23
- package/dist/helpers/logger/factory.d.ts +1 -1
- package/dist/helpers/logger/factory.js +1 -1
- package/dist/helpers/logger/index.d.ts +5 -5
- package/dist/helpers/logger/transports/dgram.transport.d.ts +2 -2
- package/dist/helpers/logger/transports/dgram.transport.js +5 -5
- package/dist/helpers/logger/transports/index.d.ts +1 -1
- package/dist/helpers/logger/types.d.ts +1 -1
- package/dist/helpers/logger/types.js +9 -9
- package/dist/helpers/network/http-request/base-network-request.helper.d.ts +12 -12
- package/dist/helpers/network/http-request/base-network-request.helper.js +10 -10
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.d.ts +5 -5
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.js +5 -5
- package/dist/helpers/network/http-request/fetcher/base-fetcher.d.ts +1 -1
- package/dist/helpers/network/http-request/fetcher/base-fetcher.js +8 -8
- package/dist/helpers/network/http-request/fetcher/index.d.ts +3 -3
- package/dist/helpers/network/http-request/fetcher/node-fetcher.d.ts +2 -2
- package/dist/helpers/network/http-request/fetcher/node-fetcher.js +6 -6
- package/dist/helpers/network/http-request/index.d.ts +2 -2
- package/dist/helpers/network/http-request/types.d.ts +4 -4
- package/dist/helpers/network/index.d.ts +3 -3
- package/dist/helpers/network/tcp-socket/base-tcp-client.helper.d.ts +4 -4
- package/dist/helpers/network/tcp-socket/base-tcp-client.helper.js +17 -17
- package/dist/helpers/network/tcp-socket/base-tcp-server.helper.d.ts +6 -6
- package/dist/helpers/network/tcp-socket/base-tcp-server.helper.js +18 -18
- package/dist/helpers/network/tcp-socket/index.d.ts +6 -6
- package/dist/helpers/network/tcp-socket/network-tcp-client.helper.d.ts +4 -4
- package/dist/helpers/network/tcp-socket/network-tcp-server.helper.d.ts +4 -4
- package/dist/helpers/network/tcp-socket/network-tls-tcp-client.helper.d.ts +4 -4
- package/dist/helpers/network/tcp-socket/network-tls-tcp-server.helper.d.ts +4 -4
- package/dist/helpers/network/udp-socket/index.d.ts +1 -1
- package/dist/helpers/network/udp-socket/network-udp-client.helper.d.ts +3 -3
- package/dist/helpers/network/udp-socket/network-udp-client.helper.js +14 -14
- package/dist/helpers/queue/bullmq/helper.d.ts +4 -4
- package/dist/helpers/queue/bullmq/helper.js +10 -10
- package/dist/helpers/queue/bullmq/index.d.ts +1 -1
- package/dist/helpers/queue/common/index.d.ts +1 -1
- package/dist/helpers/queue/common/types.d.ts +1 -1
- package/dist/helpers/queue/index.d.ts +4 -4
- package/dist/helpers/queue/internal/helper.d.ts +3 -3
- package/dist/helpers/queue/internal/helper.js +11 -11
- package/dist/helpers/queue/internal/index.d.ts +1 -1
- package/dist/helpers/queue/mqtt/helper.d.ts +2 -2
- package/dist/helpers/queue/mqtt/helper.js +8 -8
- package/dist/helpers/queue/mqtt/index.d.ts +1 -1
- package/dist/helpers/redis/cluster.helper.d.ts +3 -3
- package/dist/helpers/redis/default.helper.d.ts +3 -3
- package/dist/helpers/redis/default.helper.js +40 -40
- package/dist/helpers/redis/index.d.ts +4 -4
- package/dist/helpers/redis/single.helper.d.ts +3 -3
- package/dist/helpers/redis/types.d.ts +3 -3
- package/dist/helpers/socket-io/client/helper.d.ts +3 -3
- package/dist/helpers/socket-io/client/helper.js +8 -8
- package/dist/helpers/socket-io/client/index.d.ts +1 -1
- package/dist/helpers/socket-io/common/constants.js +10 -10
- package/dist/helpers/socket-io/common/index.d.ts +2 -2
- package/dist/helpers/socket-io/common/types.d.ts +6 -6
- package/dist/helpers/socket-io/index.d.ts +3 -3
- package/dist/helpers/socket-io/server/helper.d.ts +3 -3
- package/dist/helpers/socket-io/server/helper.js +41 -41
- package/dist/helpers/socket-io/server/index.d.ts +1 -1
- package/dist/helpers/storage/in-memory/helper.d.ts +2 -2
- package/dist/helpers/storage/in-memory/index.d.ts +1 -1
- package/dist/helpers/storage/index.d.ts +2 -2
- package/dist/helpers/storage/minio/helper.d.ts +3 -3
- package/dist/helpers/storage/minio/helper.js +7 -7
- package/dist/helpers/storage/minio/index.d.ts +1 -1
- package/dist/helpers/testing/base-test-plan.d.ts +2 -2
- package/dist/helpers/testing/base-test-plan.js +4 -4
- package/dist/helpers/testing/common/constants.d.ts +1 -1
- package/dist/helpers/testing/common/constants.js +3 -3
- package/dist/helpers/testing/common/index.d.ts +2 -2
- package/dist/helpers/testing/common/types.d.ts +3 -3
- package/dist/helpers/testing/describe.d.ts +2 -2
- package/dist/helpers/testing/describe.js +5 -5
- package/dist/helpers/testing/index.d.ts +6 -6
- package/dist/helpers/testing/test-case.d.ts +3 -3
- package/dist/helpers/testing/test-case.js +1 -1
- package/dist/helpers/testing/test-handler.d.ts +3 -3
- package/dist/helpers/testing/test-handler.js +2 -2
- package/dist/helpers/testing/test-plan.d.ts +2 -2
- package/dist/helpers/worker-thread/base.d.ts +6 -6
- package/dist/helpers/worker-thread/base.js +15 -15
- package/dist/helpers/worker-thread/base.js.map +1 -1
- package/dist/helpers/worker-thread/index.d.ts +4 -4
- package/dist/helpers/worker-thread/types.d.ts +2 -2
- package/dist/helpers/worker-thread/worker-bus.d.ts +4 -4
- package/dist/helpers/worker-thread/worker-bus.d.ts.map +1 -1
- package/dist/helpers/worker-thread/worker-bus.js +14 -9
- package/dist/helpers/worker-thread/worker-bus.js.map +1 -1
- package/dist/helpers/worker-thread/worker-pool.d.ts +2 -2
- package/dist/helpers/worker-thread/worker-pool.js +6 -6
- package/dist/index.d.ts +4 -4
- package/dist/utilities/crypto.utility.d.ts +1 -1
- package/dist/utilities/crypto.utility.js +2 -2
- package/dist/utilities/date.utility.d.ts +1 -1
- package/dist/utilities/date.utility.js +6 -6
- package/dist/utilities/index.d.ts +7 -7
- package/dist/utilities/module.utility.js +2 -2
- package/dist/utilities/parse.utility.js +18 -18
- package/dist/utilities/performance.utility.d.ts +1 -1
- package/dist/utilities/performance.utility.js +5 -5
- package/dist/utilities/promise.utility.d.ts +1 -1
- package/dist/utilities/promise.utility.js +3 -3
- package/dist/utilities/request.utility.d.ts +1 -1
- package/dist/utilities/request.utility.js +7 -7
- package/package.json +23 -29
package/LICENSE.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Ignis Framework License
|
|
2
|
+
|
|
3
|
+
Ignis is a TypeScript Server Infrastructure framework built on [Hono](https://hono.dev/).
|
|
4
|
+
|
|
5
|
+
## MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 VENIZIA Ltd. Co.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Packages
|
|
30
|
+
|
|
31
|
+
This monorepo contains the following packages, all licensed under MIT:
|
|
32
|
+
|
|
33
|
+
| Package | Description |
|
|
34
|
+
|---------|-------------|
|
|
35
|
+
| `@venizia/ignis` | Core framework - controllers, services, decorators |
|
|
36
|
+
| `@venizia/ignis-helpers` | Utility helpers - logging, cron, Redis, queues, storage |
|
|
37
|
+
| `@venizia/ignis-inversion` | Dependency Injection & IoC container |
|
|
38
|
+
| `@venizia/dev-configs` | Shared ESLint, Prettier, TypeScript configurations |
|
|
39
|
+
| `@venizia/ignis-docs` | Documentation and MCP Server |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Third-Party Dependencies
|
|
44
|
+
|
|
45
|
+
Ignis uses the following open-source libraries. We are grateful to the authors and contributors of these projects.
|
|
46
|
+
|
|
47
|
+
### Core Dependencies
|
|
48
|
+
|
|
49
|
+
| Library | License | Description |
|
|
50
|
+
|---------|---------|-------------|
|
|
51
|
+
| [Hono](https://github.com/honojs/hono) | MIT | Ultrafast web framework |
|
|
52
|
+
| [Zod](https://github.com/colinhacks/zod) | MIT | TypeScript-first schema validation |
|
|
53
|
+
| [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm) | Apache-2.0 | TypeScript ORM |
|
|
54
|
+
| [Jose](https://github.com/panva/jose) | MIT | JavaScript Object Signing and Encryption |
|
|
55
|
+
|
|
56
|
+
### Helpers Dependencies
|
|
57
|
+
|
|
58
|
+
| Library | License | Description |
|
|
59
|
+
|---------|---------|-------------|
|
|
60
|
+
| [Winston](https://github.com/winstonjs/winston) | MIT | Universal logging library |
|
|
61
|
+
| [BullMQ](https://github.com/taskforcesh/bullmq) | MIT | Message queue and job scheduling |
|
|
62
|
+
| [IORedis](https://github.com/redis/ioredis) | MIT | Redis client for Node.js |
|
|
63
|
+
| [MinIO](https://github.com/minio/minio-js) | Apache-2.0 | S3-compatible object storage client |
|
|
64
|
+
| [Axios](https://github.com/axios/axios) | MIT | HTTP client |
|
|
65
|
+
| [Day.js](https://github.com/iamkun/dayjs) | MIT | Date manipulation library |
|
|
66
|
+
| [Cron](https://github.com/kelektiv/node-cron) | MIT | Cron job scheduler |
|
|
67
|
+
| [Socket.IO](https://github.com/socketio/socket.io) | MIT | Real-time bidirectional communication |
|
|
68
|
+
| [MQTT.js](https://github.com/mqttjs/MQTT.js) | MIT | MQTT client |
|
|
69
|
+
|
|
70
|
+
### Utility Dependencies
|
|
71
|
+
|
|
72
|
+
| Library | License | Description |
|
|
73
|
+
|---------|---------|-------------|
|
|
74
|
+
| [Lodash](https://github.com/lodash/lodash) | MIT | Utility library |
|
|
75
|
+
| [reflect-metadata](https://github.com/rbuckton/reflect-metadata) | Apache-2.0 | Metadata reflection API |
|
|
76
|
+
|
|
77
|
+
### Documentation Dependencies
|
|
78
|
+
|
|
79
|
+
| Library | License | Description |
|
|
80
|
+
|---------|---------|-------------|
|
|
81
|
+
| [VitePress](https://github.com/vuejs/vitepress) | MIT | Static site generator |
|
|
82
|
+
| [Fuse.js](https://github.com/krisk/fuse) | Apache-2.0 | Fuzzy search library |
|
|
83
|
+
| [gray-matter](https://github.com/jonschlinkert/gray-matter) | MIT | Front-matter parser |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Acknowledgments
|
|
88
|
+
|
|
89
|
+
Ignis Framework is inspired by and built upon the work of many open-source projects:
|
|
90
|
+
|
|
91
|
+
- **[Hono](https://hono.dev/)** by Yusuke Wada - The ultrafast web framework that powers Ignis
|
|
92
|
+
- **[LoopBack 4](https://loopback.io/)** by IBM/StrongLoop - Inspiration for the enterprise architecture patterns
|
|
93
|
+
- **[NestJS](https://nestjs.com/)** by Kamil Mysliwiec - Inspiration for decorator-based controllers
|
|
94
|
+
- **[InversifyJS](https://inversify.io/)** - Inspiration for the IoC container design
|
|
95
|
+
|
|
96
|
+
We thank all the maintainers and contributors of these projects for their excellent work.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Contributing
|
|
101
|
+
|
|
102
|
+
By contributing to Ignis, you agree that your contributions will be licensed under the MIT License.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @venizia/ignis-helpers
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@venizia/ignis-helpers)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A collection of **helpers and utilities** for the **Ignis Framework** - includes logging, cron jobs, Redis, queues, storage, and more.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bun add @venizia/ignis-helpers
|
|
12
|
+
# or
|
|
13
|
+
npm install @venizia/ignis-helpers
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Available Helpers
|
|
17
|
+
|
|
18
|
+
| Helper | Description |
|
|
19
|
+
|--------|-------------|
|
|
20
|
+
| **Logger** | Winston-based logging with daily rotation |
|
|
21
|
+
| **Cron** | Scheduled job management |
|
|
22
|
+
| **Redis** | Redis client wrapper with IoRedis |
|
|
23
|
+
| **Queue** | BullMQ-based job queue |
|
|
24
|
+
| **Storage** | MinIO/S3-compatible object storage |
|
|
25
|
+
| **Crypto** | Encryption and hashing utilities |
|
|
26
|
+
| **Network** | HTTP client with Axios |
|
|
27
|
+
| **Socket.IO** | Real-time communication helpers |
|
|
28
|
+
| **Error** | Standardized error handling |
|
|
29
|
+
| **Env** | Environment variable management |
|
|
30
|
+
|
|
31
|
+
## About Ignis
|
|
32
|
+
|
|
33
|
+
Ignis brings together the structured, enterprise development experience of **LoopBack 4** with the blazing speed and simplicity of **Hono** - giving you the best of both worlds.
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
- [Ignis Repository](https://github.com/venizia-ai/ignis)
|
|
38
|
+
- [Getting Started](https://github.com/venizia-ai/ignis/blob/main/packages/docs/wiki/get-started/index.md)
|
|
39
|
+
- [Helpers Reference](https://github.com/venizia-ai/ignis/blob/main/packages/docs/wiki/references/helpers/index.md)
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
|
@@ -3,24 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataTypes = exports.RuntimeModules = exports.Defaults = void 0;
|
|
4
4
|
// ------------------------------------------------------------------------------
|
|
5
5
|
class Defaults {
|
|
6
|
-
static { this.APPLICATION_NAME = process.env.APP_ENV_APPLICATION_NAME ??
|
|
6
|
+
static { this.APPLICATION_NAME = process.env.APP_ENV_APPLICATION_NAME ?? 'APP'; }
|
|
7
7
|
static { this.QUERY_LIMIT = 50; }
|
|
8
8
|
static { this.QUERY_OFFSET = 0; }
|
|
9
9
|
}
|
|
10
10
|
exports.Defaults = Defaults;
|
|
11
11
|
// ------------------------------------------------------------------------------
|
|
12
12
|
class RuntimeModules {
|
|
13
|
-
static { this.NODE =
|
|
14
|
-
static { this.BUN =
|
|
13
|
+
static { this.NODE = 'node'; }
|
|
14
|
+
static { this.BUN = 'bun'; }
|
|
15
15
|
}
|
|
16
16
|
exports.RuntimeModules = RuntimeModules;
|
|
17
17
|
// ------------------------------------------------------------------------------
|
|
18
18
|
class DataTypes {
|
|
19
|
-
static { this.NUMBER =
|
|
20
|
-
static { this.TEXT =
|
|
21
|
-
static { this.BYTE =
|
|
22
|
-
static { this.JSON =
|
|
23
|
-
static { this.BOOLEAN =
|
|
19
|
+
static { this.NUMBER = 'NUMBER'; }
|
|
20
|
+
static { this.TEXT = 'TEXT'; }
|
|
21
|
+
static { this.BYTE = 'BYTE'; }
|
|
22
|
+
static { this.JSON = 'JSON'; }
|
|
23
|
+
static { this.BOOLEAN = 'BOOLEAN'; }
|
|
24
24
|
static { this.SCHEME_SET = new Set([
|
|
25
25
|
this.NUMBER,
|
|
26
26
|
this.TEXT,
|
|
@@ -3,23 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HTTP = void 0;
|
|
4
4
|
class HTTP {
|
|
5
5
|
static { this.Headers = {
|
|
6
|
-
AUTHORIZATION:
|
|
7
|
-
REQUEST_TRACING_ID:
|
|
6
|
+
AUTHORIZATION: 'authorization',
|
|
7
|
+
REQUEST_TRACING_ID: 'x-request-id',
|
|
8
8
|
}; }
|
|
9
9
|
static { this.HeaderValues = {
|
|
10
|
-
APPLICATION_JSON:
|
|
11
|
-
APPLICATION_FORM_URLENCODED:
|
|
12
|
-
TEXT_PLAIN:
|
|
13
|
-
MULTIPART_FORM_DATA:
|
|
10
|
+
APPLICATION_JSON: 'application/json',
|
|
11
|
+
APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',
|
|
12
|
+
TEXT_PLAIN: 'text/plain',
|
|
13
|
+
MULTIPART_FORM_DATA: 'multipart/form-data',
|
|
14
14
|
}; }
|
|
15
15
|
static { this.Methods = {
|
|
16
|
-
GET:
|
|
17
|
-
POST:
|
|
18
|
-
PUT:
|
|
19
|
-
PATCH:
|
|
20
|
-
DELETE:
|
|
21
|
-
HEAD:
|
|
22
|
-
OPTIONS:
|
|
16
|
+
GET: 'get',
|
|
17
|
+
POST: 'post',
|
|
18
|
+
PUT: 'put',
|
|
19
|
+
PATCH: 'patch',
|
|
20
|
+
DELETE: 'delete',
|
|
21
|
+
HEAD: 'head',
|
|
22
|
+
OPTIONS: 'options',
|
|
23
23
|
}; }
|
|
24
24
|
static { this.ResultCodes = {
|
|
25
25
|
RS_FAIL: 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './app';
|
|
2
|
+
export * from './http';
|
|
3
|
+
export * from './mime';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MimeTypes = void 0;
|
|
4
4
|
class MimeTypes {
|
|
5
|
-
static { this.UNKNOWN =
|
|
6
|
-
static { this.IMAGE =
|
|
7
|
-
static { this.VIDEO =
|
|
8
|
-
static { this.TEXT =
|
|
5
|
+
static { this.UNKNOWN = 'unknown'; }
|
|
6
|
+
static { this.IMAGE = 'image'; }
|
|
7
|
+
static { this.VIDEO = 'video'; }
|
|
8
|
+
static { this.TEXT = 'text'; }
|
|
9
9
|
}
|
|
10
10
|
exports.MimeTypes = MimeTypes;
|
|
11
11
|
//# sourceMappingURL=mime.js.map
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './types';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/common/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Container } from
|
|
1
|
+
import { Container } from '../helpers/inversion';
|
|
2
2
|
export type TNullable<T> = T | undefined | null;
|
|
3
3
|
export type AnyType = any;
|
|
4
4
|
export type AnyObject = Record<string | symbol | number, any>;
|
|
@@ -28,43 +28,43 @@ export type TPrettify<T> = {
|
|
|
28
28
|
[K in keyof T]: T[K];
|
|
29
29
|
} & {};
|
|
30
30
|
export type TResolver<T> = (...args: any[]) => T;
|
|
31
|
-
export type TFieldMappingDataType =
|
|
31
|
+
export type TFieldMappingDataType = 'string' | 'number' | 'strings' | 'numbers' | 'boolean';
|
|
32
32
|
export interface IFieldMapping {
|
|
33
33
|
name: string;
|
|
34
34
|
type: TFieldMappingDataType;
|
|
35
35
|
default?: string | number | Array<string> | Array<number> | boolean;
|
|
36
36
|
}
|
|
37
37
|
export type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<T[number], {
|
|
38
|
-
type: Exclude<T[number][
|
|
39
|
-
}>[
|
|
38
|
+
type: Exclude<T[number]['type'], undefined>;
|
|
39
|
+
}>['name'];
|
|
40
40
|
export type TObjectFromFieldMappings<T extends readonly {
|
|
41
41
|
name: string;
|
|
42
42
|
type: string;
|
|
43
43
|
[extra: string | symbol]: any;
|
|
44
44
|
}[]> = {
|
|
45
|
-
[K in T[number][
|
|
45
|
+
[K in T[number]['name']]: T extends {
|
|
46
46
|
name: K;
|
|
47
|
-
type:
|
|
47
|
+
type: 'string';
|
|
48
48
|
[extra: string | symbol]: any;
|
|
49
49
|
} ? string : T extends {
|
|
50
50
|
name: K;
|
|
51
|
-
type:
|
|
51
|
+
type: 'number';
|
|
52
52
|
[extra: string | symbol]: any;
|
|
53
53
|
} ? number : T extends {
|
|
54
54
|
name: K;
|
|
55
|
-
type:
|
|
55
|
+
type: 'boolean';
|
|
56
56
|
[extra: string | symbol]: any;
|
|
57
57
|
} ? boolean : T extends {
|
|
58
58
|
name: K;
|
|
59
|
-
type:
|
|
59
|
+
type: 'strings';
|
|
60
60
|
[extra: string | symbol]: any;
|
|
61
61
|
} ? string[] : T extends {
|
|
62
62
|
name: K;
|
|
63
|
-
type:
|
|
63
|
+
type: 'numbers';
|
|
64
64
|
[extra: string | symbol]: any;
|
|
65
65
|
} ? number[] : never;
|
|
66
66
|
};
|
|
67
|
-
export type TPermissionEffect =
|
|
67
|
+
export type TPermissionEffect = 'allow' | 'deny';
|
|
68
68
|
export type TInjectionGetter = <T>(opts: {
|
|
69
69
|
key: string | symbol;
|
|
70
70
|
}) => T;
|
|
@@ -76,6 +76,6 @@ export interface IProvider<T> {
|
|
|
76
76
|
}
|
|
77
77
|
export declare const isClass: <T>(target: any) => target is TClass<T>;
|
|
78
78
|
export declare const isClassProvider: <T>(target: any) => target is TClass<IProvider<T>>;
|
|
79
|
-
export type TAuthStrategy =
|
|
80
|
-
export type { FC, PropsWithChildren, Child } from
|
|
79
|
+
export type TAuthStrategy = 'jwt' | 'basic';
|
|
80
|
+
export type { FC, PropsWithChildren, Child } from 'hono/jsx';
|
|
81
81
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/common/types.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isClassProvider = exports.isClass = void 0;
|
|
4
4
|
const isClass = (target) => {
|
|
5
|
-
return typeof target ===
|
|
5
|
+
return typeof target === 'function' && target.prototype !== undefined;
|
|
6
6
|
};
|
|
7
7
|
exports.isClass = isClass;
|
|
8
8
|
const isClassProvider = (target) => {
|
|
9
|
-
return (typeof target ===
|
|
9
|
+
return (typeof target === 'function' && target.prototype && typeof target.prototype.value === 'function');
|
|
10
10
|
};
|
|
11
11
|
exports.isClassProvider = isClassProvider;
|
|
12
12
|
//# sourceMappingURL=types.js.map
|
package/dist/helpers/base.d.ts
CHANGED
package/dist/helpers/base.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.BaseHelper = void 0;
|
|
|
4
4
|
const logger_1 = require("../helpers/logger");
|
|
5
5
|
class BaseHelper {
|
|
6
6
|
constructor(opts) {
|
|
7
|
-
this.logger = logger_1.LoggerFactory.getLogger([opts.scope, opts.identifier ??
|
|
8
|
-
this.scope = opts.scope ??
|
|
9
|
-
this.identifier = opts.identifier ??
|
|
7
|
+
this.logger = logger_1.LoggerFactory.getLogger([opts.scope, opts.identifier ?? ''].filter(el => el && el.length > 0));
|
|
8
|
+
this.scope = opts.scope ?? '';
|
|
9
|
+
this.identifier = opts.identifier ?? '';
|
|
10
10
|
}
|
|
11
11
|
getIdentifier() {
|
|
12
12
|
return this.identifier;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseHelper } from
|
|
2
|
-
import { CronJob, CronOnCompleteCommand } from
|
|
1
|
+
import { BaseHelper } from '../../helpers/base';
|
|
2
|
+
import { CronJob, CronOnCompleteCommand } from 'cron';
|
|
3
3
|
export interface ICronHelperOptions {
|
|
4
4
|
cronTime: string;
|
|
5
5
|
onTick: () => void | Promise<void>;
|
|
@@ -27,7 +27,7 @@ class CronHelper extends base_1.BaseHelper {
|
|
|
27
27
|
configure() {
|
|
28
28
|
if (!this.cronTime || (0, isEmpty_1.default)(this.cronTime)) {
|
|
29
29
|
throw error_1.ApplicationError.getError({
|
|
30
|
-
message:
|
|
30
|
+
message: '[CronHelper][configure] Invalid cronTime to configure application cron!',
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
this.instance = cron_1.CronJob.from({
|
|
@@ -41,7 +41,7 @@ class CronHelper extends base_1.BaseHelper {
|
|
|
41
41
|
}
|
|
42
42
|
start() {
|
|
43
43
|
if (!this.instance) {
|
|
44
|
-
this.logger.error(
|
|
44
|
+
this.logger.error('[CronHelper][start] Invalid cron instance to start cronjob!');
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
this.instance.start();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './cron.helper';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import C from
|
|
2
|
-
import { BaseCryptoAlgorithm } from
|
|
1
|
+
import C from 'node:crypto';
|
|
2
|
+
import { BaseCryptoAlgorithm } from './base.algorithm';
|
|
3
3
|
interface IO {
|
|
4
4
|
iv?: Buffer;
|
|
5
5
|
inputEncoding?: C.Encoding;
|
|
6
6
|
outputEncoding?: C.Encoding;
|
|
7
7
|
doThrow?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export type AESAlgorithmType =
|
|
9
|
+
export type AESAlgorithmType = 'aes-256-cbc' | 'aes-256-gcm';
|
|
10
10
|
export declare class AES extends BaseCryptoAlgorithm<AESAlgorithmType, IO> {
|
|
11
11
|
constructor(opts: {
|
|
12
12
|
algorithm: AESAlgorithmType;
|
|
@@ -17,7 +17,7 @@ class AES extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
17
17
|
return new AES({ algorithm });
|
|
18
18
|
}
|
|
19
19
|
encrypt(message, secret, opts) {
|
|
20
|
-
const { iv = node_crypto_1.default.randomBytes(DEFAULT_LENGTH), inputEncoding =
|
|
20
|
+
const { iv = node_crypto_1.default.randomBytes(DEFAULT_LENGTH), inputEncoding = 'utf-8', outputEncoding = 'base64', doThrow = true, } = opts ?? {};
|
|
21
21
|
try {
|
|
22
22
|
const secretKey = this.normalizeSecretKey({
|
|
23
23
|
secret,
|
|
@@ -28,10 +28,10 @@ class AES extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
28
28
|
const cipherText = cipher.update(message, inputEncoding);
|
|
29
29
|
const cipherFinal = cipher.final();
|
|
30
30
|
switch (this.algorithm) {
|
|
31
|
-
case
|
|
31
|
+
case 'aes-256-cbc': {
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
|
-
case
|
|
34
|
+
case 'aes-256-gcm': {
|
|
35
35
|
parts.push(cipher.getAuthTag());
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -49,15 +49,15 @@ class AES extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
49
49
|
}
|
|
50
50
|
encryptFile(absolutePath, secret) {
|
|
51
51
|
if (!absolutePath || (0, isEmpty_1.default)(absolutePath)) {
|
|
52
|
-
return
|
|
52
|
+
return '';
|
|
53
53
|
}
|
|
54
54
|
const buffer = node_fs_1.default.readFileSync(absolutePath);
|
|
55
|
-
const fileContent = buffer?.toString(
|
|
55
|
+
const fileContent = buffer?.toString('utf-8');
|
|
56
56
|
const encrypted = this.encrypt(fileContent, secret);
|
|
57
57
|
return encrypted;
|
|
58
58
|
}
|
|
59
59
|
decrypt(message, secret, opts) {
|
|
60
|
-
const { inputEncoding =
|
|
60
|
+
const { inputEncoding = 'base64', outputEncoding = 'utf-8', doThrow = true } = opts ?? {};
|
|
61
61
|
try {
|
|
62
62
|
const iv = opts?.iv ??
|
|
63
63
|
Buffer.from(message, inputEncoding).subarray(0, DEFAULT_LENGTH) ??
|
|
@@ -69,10 +69,10 @@ class AES extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
69
69
|
});
|
|
70
70
|
const decipher = node_crypto_1.default.createDecipheriv(this.algorithm, Buffer.from(secretKey), iv);
|
|
71
71
|
switch (this.algorithm) {
|
|
72
|
-
case
|
|
72
|
+
case 'aes-256-cbc': {
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
|
-
case
|
|
75
|
+
case 'aes-256-gcm': {
|
|
76
76
|
const authTag = Buffer.from(message, inputEncoding).subarray(iv.length, iv.length + DEFAULT_LENGTH);
|
|
77
77
|
messageIndex += authTag.length;
|
|
78
78
|
decipher.setAuthTag(authTag);
|
|
@@ -91,10 +91,10 @@ class AES extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
91
91
|
}
|
|
92
92
|
decryptFile(absolutePath, secret) {
|
|
93
93
|
if (!absolutePath || (0, isEmpty_1.default)(absolutePath)) {
|
|
94
|
-
return
|
|
94
|
+
return '';
|
|
95
95
|
}
|
|
96
96
|
const buffer = node_fs_1.default.readFileSync(absolutePath);
|
|
97
|
-
const fileContent = buffer?.toString(
|
|
97
|
+
const fileContent = buffer?.toString('utf-8');
|
|
98
98
|
const decrypted = this.decrypt(fileContent, secret);
|
|
99
99
|
return decrypted;
|
|
100
100
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseHelper } from
|
|
2
|
-
import { ICryptoAlgorithm } from
|
|
1
|
+
import { BaseHelper } from '../../../helpers/base';
|
|
2
|
+
import { ICryptoAlgorithm } from '../common';
|
|
3
3
|
export declare abstract class AbstractCryptoAlgorithm<AL extends string, IO> extends BaseHelper implements ICryptoAlgorithm<AL, IO> {
|
|
4
4
|
algorithm: AL;
|
|
5
5
|
abstract encrypt(message: string, secret: string, opts?: IO | undefined): string;
|
|
@@ -33,7 +33,7 @@ class BaseCryptoAlgorithm extends AbstractCryptoAlgorithm {
|
|
|
33
33
|
return secret.padEnd(length, padEnd);
|
|
34
34
|
}
|
|
35
35
|
getAlgorithmKeySize() {
|
|
36
|
-
const b = (0, utilities_1.int)(this.algorithm?.split(
|
|
36
|
+
const b = (0, utilities_1.int)(this.algorithm?.split('-')?.[1] ?? common_1.DEFAULT_CIPHER_BITS);
|
|
37
37
|
return (0, utilities_1.int)(b / 8);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './base.algorithm';
|
|
2
|
+
export * from './aes.algorithm';
|
|
3
|
+
export * from './rsa.algorithm';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import C from
|
|
2
|
-
import { BaseCryptoAlgorithm } from
|
|
1
|
+
import C from 'node:crypto';
|
|
2
|
+
import { BaseCryptoAlgorithm } from './base.algorithm';
|
|
3
3
|
interface IO {
|
|
4
4
|
inputEncoding?: {
|
|
5
5
|
key: C.Encoding;
|
|
@@ -8,7 +8,7 @@ interface IO {
|
|
|
8
8
|
outputEncoding?: C.Encoding;
|
|
9
9
|
doThrow?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export type RSAAlgorithmType =
|
|
11
|
+
export type RSAAlgorithmType = 'rsa';
|
|
12
12
|
export declare class RSA extends BaseCryptoAlgorithm<RSAAlgorithmType, IO> {
|
|
13
13
|
constructor(opts: {
|
|
14
14
|
algorithm: RSAAlgorithmType;
|
|
@@ -11,24 +11,24 @@ class RSA extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
11
11
|
super({ scope: RSA.name, ...opts });
|
|
12
12
|
}
|
|
13
13
|
static withAlgorithm() {
|
|
14
|
-
return new RSA({ algorithm:
|
|
14
|
+
return new RSA({ algorithm: 'rsa' });
|
|
15
15
|
}
|
|
16
16
|
generateDERKeyPair(opts) {
|
|
17
|
-
const keys = node_crypto_1.default.generateKeyPairSync(
|
|
17
|
+
const keys = node_crypto_1.default.generateKeyPairSync('rsa', {
|
|
18
18
|
modulusLength: opts?.modulus ?? 1199,
|
|
19
19
|
});
|
|
20
20
|
return {
|
|
21
|
-
publicKey: keys.publicKey.export({ type:
|
|
22
|
-
privateKey: keys.privateKey.export({ type:
|
|
21
|
+
publicKey: keys.publicKey.export({ type: 'spki', format: 'der' }),
|
|
22
|
+
privateKey: keys.privateKey.export({ type: 'pkcs8', format: 'der' }),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
encrypt(message, pubKey, opts) {
|
|
26
|
-
const { inputEncoding = { key:
|
|
26
|
+
const { inputEncoding = { key: 'base64', message: 'utf-8' }, outputEncoding = 'base64', doThrow = true, } = opts ?? {};
|
|
27
27
|
try {
|
|
28
28
|
const k = node_crypto_1.default.createPublicKey({
|
|
29
29
|
key: Buffer.from(pubKey, inputEncoding.key),
|
|
30
|
-
format:
|
|
31
|
-
type:
|
|
30
|
+
format: 'der',
|
|
31
|
+
type: 'spki',
|
|
32
32
|
});
|
|
33
33
|
const rs = node_crypto_1.default.publicEncrypt(k, Buffer.from(message, inputEncoding.message));
|
|
34
34
|
return rs.toString(outputEncoding);
|
|
@@ -41,12 +41,12 @@ class RSA extends base_algorithm_1.BaseCryptoAlgorithm {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
decrypt(message, privKey, opts) {
|
|
44
|
-
const { inputEncoding = { key:
|
|
44
|
+
const { inputEncoding = { key: 'base64', message: 'base64' }, outputEncoding = 'utf-8', doThrow = true, } = opts ?? {};
|
|
45
45
|
try {
|
|
46
46
|
const k = node_crypto_1.default.createPrivateKey({
|
|
47
47
|
key: Buffer.from(privKey, inputEncoding.key),
|
|
48
|
-
format:
|
|
49
|
-
type:
|
|
48
|
+
format: 'der',
|
|
49
|
+
type: 'pkcs8',
|
|
50
50
|
});
|
|
51
51
|
const rs = node_crypto_1.default.privateDecrypt(k, Buffer.from(message, inputEncoding.message));
|
|
52
52
|
return rs.toString(outputEncoding);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './constants';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './algorithms';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|