@bts-soft/core 1.1.4 → 1.2.5
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 +29 -194
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,216 +1,51 @@
|
|
|
1
|
-
# @bts-soft/core | The BTS Software Core Toolkit
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# @bts-soft/core
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
The **Core Package** is the main entry point of the **BTS Soft ecosystem**.
|
|
5
|
+
It bundles and re-exports all common utilities and modules used across different BTS packages, allowing developers to integrate them easily into any NestJS project.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Features
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|**Validation Toolkit**|`@bts-soft/validation`|Powerful, region-aware decorators for secure, consistent DTO validation.|
|
|
15
|
-
|**Config Module**|`@bts-soft/config`|Global, cached, and environment-based configuration loading.|
|
|
11
|
+
- Centralized import for all BTS Soft modules
|
|
12
|
+
- Simplifies project setup and maintenance
|
|
13
|
+
- Works seamlessly with both REST and GraphQL environments
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
---
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## Included Packages
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
- [@bts-soft/validation]([@bts-soft/validation - npm](https://www.npmjs.com/package/@bts-soft/validation)) — Input validation utilities & decorators
|
|
20
|
+
- [@bts-soft/upload]([@bts-soft/mail-queue - npm](https://www.npmjs.com/package/@bts-soft/upload)) — File upload middleware (GraphQL & REST)
|
|
21
|
+
- [@bts-soft/mail-queue]([@bts-soft/mail-queue - npm](https://www.npmjs.com/package/@bts-soft/mail-queue)) — Email queue handling with BullMQ
|
|
22
|
+
- [@bts-soft/config]([@bts-soft/mail-queue - npm](https://www.npmjs.com/package/@bts-soft/config)) — Environment & configuration management
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
npm install @bts-soft/core
|
|
25
|
-
```
|
|
24
|
+
---
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
## Usage Example
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|Variable|Usage|
|
|
32
|
-
|---|---|
|
|
33
|
-
|`REDIS_HOST`, `REDIS_PORT`|Required for BullMQ queue management.|
|
|
34
|
-
|`MAIL_HOST`, `MAIL_USER`, `MAIL_PASS`|Required for Nodemailer SMTP connection.|
|
|
35
|
-
|`NODE_ENV`|Used by ConfigModule to determine which `.env` file to load.|
|
|
36
|
-
|
|
37
|
-
### 3. Usage in AppModule
|
|
38
|
-
|
|
39
|
-
All modules are designed to be imported directly from `@bts-soft/core`.
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
// app.module.ts
|
|
28
|
+
```ts
|
|
43
29
|
import { Module } from '@nestjs/common';
|
|
44
|
-
import {
|
|
45
|
-
|
|
30
|
+
import { CoreModule } from '@bts-soft/core';
|
|
31
|
+
|
|
46
32
|
@Module({
|
|
47
|
-
|
|
48
|
-
ConfigModule, // Global environment loader
|
|
49
|
-
EmailModule.register({
|
|
50
|
-
// Optional: Custom configuration overrides
|
|
51
|
-
}),
|
|
52
|
-
],
|
|
33
|
+
imports: [CoreModule],
|
|
53
34
|
})
|
|
54
35
|
export class AppModule {}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### 4. Injecting and Using Services
|
|
58
|
-
|
|
59
|
-
Access any service directly from the core package:
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
// my.service.ts
|
|
63
|
-
import { Injectable } from '@nestjs/common';
|
|
64
|
-
import { SendEmailService } from '@bts-soft/core';
|
|
65
|
-
|
|
66
|
-
@Injectable()
|
|
67
|
-
export class MyService {
|
|
68
|
-
constructor(private readonly emailService: SendEmailService) {}
|
|
69
|
-
|
|
70
|
-
async handleSignup(user: any) {
|
|
71
|
-
await this.emailService.sendEmail(
|
|
72
|
-
user.email,
|
|
73
|
-
'Welcome!',
|
|
74
|
-
'Thanks for signing up to our platform.'
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Architecture Overview
|
|
81
|
-
|
|
82
|
-
The **`@bts-soft/core`** package follows a **modular and scalable monorepo architecture**, designed to unify all backend modules under one shared entry point.
|
|
83
|
-
|
|
84
|
-
This approach ensures:
|
|
85
|
-
|
|
86
|
-
- **Consistency** across projects
|
|
87
|
-
|
|
88
|
-
- **Reusability** of core modules
|
|
89
|
-
|
|
90
|
-
- **Encapsulation** and clean module separation
|
|
91
|
-
|
|
92
|
-
- **Ease of expansion** for future internal packages
|
|
93
|
-
|
|
36
|
+
````
|
|
94
37
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
bts-soft/
|
|
99
|
-
├── packages/
|
|
100
|
-
│ ├── core/ # Main Core package (unified entry point)
|
|
101
|
-
│ │ ├── src/
|
|
102
|
-
│ │ │ ├── modules/
|
|
103
|
-
│ │ │ │ ├── email/ # Email Queue Module
|
|
104
|
-
│ │ │ │ ├── validation/ # Validation Module
|
|
105
|
-
│ │ │ │ ├── config/ # Config Loader
|
|
106
|
-
│ │ │ │ └── index.ts # Re-exports all submodules
|
|
107
|
-
│ │ │ ├── utils/ # Shared utilities
|
|
108
|
-
│ │ │ └── index.ts # Unified Core export
|
|
109
|
-
│ │ └── package.json
|
|
110
|
-
│ ├── mail-queue/ # BullMQ + Nodemailer integration
|
|
111
|
-
│ ├── validation/ # DTO and field decorators
|
|
112
|
-
│ └── config/ # Environment management
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Modular Design Philosophy
|
|
116
|
-
|
|
117
|
-
Each module in `@bts-soft/core` is designed to be:
|
|
118
|
-
|
|
119
|
-
|Principle|Description|
|
|
120
|
-
|---|---|
|
|
121
|
-
|**Isolated**|Each submodule (email, validation, config) is self-contained.|
|
|
122
|
-
|**Composable**|Modules can be imported individually or all together via Core.|
|
|
123
|
-
|**Extensible**|New modules (e.g. logger, cache) can be added easily.|
|
|
124
|
-
|**Global-ready**|Config and Validation can be registered globally.|
|
|
125
|
-
|
|
126
|
-
### Example: Unified Export (`index.ts`)
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
// packages/core/src/index.ts
|
|
130
|
-
export * from './modules/email';
|
|
131
|
-
export * from './modules/validation';
|
|
132
|
-
export * from './modules/config';
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Then you can access everything from one place:
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
import {
|
|
139
|
-
EmailModule,
|
|
140
|
-
SendEmailService,
|
|
141
|
-
ConfigModule,
|
|
142
|
-
ValidationModule,
|
|
143
|
-
IdField,
|
|
144
|
-
TextField,
|
|
145
|
-
} from '@bts-soft/core';
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Internal Interaction Diagram
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
graph TD
|
|
152
|
-
A[@bts-soft/config] -->|Loads .env based on NODE_ENV| B
|
|
153
|
-
B[@bts-soft/mail-queue] -->|Uses Redis + SMTP configs| C
|
|
154
|
-
C[@bts-soft/validation] -->|Provides decorators and validators| D
|
|
155
|
-
D[Core Package: @bts-soft/core]
|
|
156
|
-
A --> D
|
|
157
|
-
B --> D
|
|
158
|
-
C --> D
|
|
159
|
-
style D fill:#f9f,stroke:#333,stroke-width:2px
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
The **Core package** (`@bts-soft/core`) re-exports them all, providing a **single point of access** for developers.
|
|
163
|
-
|
|
164
|
-
### Developer Workflow Example
|
|
165
|
-
|
|
166
|
-
1. Install one package: `npm install @bts-soft/core`
|
|
167
|
-
|
|
168
|
-
2. Import what you need: `import { ConfigModule, EmailModule, IdField } from '@bts-soft/core';`
|
|
169
|
-
|
|
170
|
-
3. Configure via `.env`: `NODE_ENV=development REDIS_HOST=localhost MAIL_USER=myapp@gmail.com`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Everything else works automatically
|
|
174
|
-
|
|
175
|
-
## Example: Config Module
|
|
38
|
+
---
|
|
176
39
|
|
|
177
|
-
|
|
178
|
-
import { Module } from '@nestjs/common';
|
|
179
|
-
import { ConfigModule as config } from '@nestjs/config';
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* @Module ConfigModule
|
|
183
|
-
* Handles environment variable management for consistent configuration
|
|
184
|
-
* across the entire monorepo.
|
|
185
|
-
*/
|
|
186
|
-
@Module({
|
|
187
|
-
imports: [
|
|
188
|
-
config.forRoot({
|
|
189
|
-
cache: true, // Cache .env values for better performance
|
|
190
|
-
isGlobal: true, // Makes it globally available across modules
|
|
191
|
-
envFilePath: `.env.${process.env.NODE_ENV || 'development'}`, // Dynamic file loading
|
|
192
|
-
}),
|
|
193
|
-
],
|
|
194
|
-
})
|
|
195
|
-
export class ConfigModule {}
|
|
196
|
-
```
|
|
40
|
+
## Learn More
|
|
197
41
|
|
|
198
|
-
|
|
42
|
+
Visit each module’s documentation for details and advanced usage examples:
|
|
199
43
|
|
|
200
|
-
-
|
|
44
|
+
- [Validation Documentation]([@bts-soft/validation - npm](https://www.npmjs.com/package/@bts-soft/validation))
|
|
201
45
|
|
|
202
|
-
-
|
|
46
|
+
- [Upload Documentation]([@bts-soft/validation - npm](https://www.npmjs.com/package/@bts-soft/upload))
|
|
203
47
|
|
|
204
|
-
-
|
|
48
|
+
- [Mail Queue Documentation]([@bts-soft/mail-queue - npm](https://www.npmjs.com/package/@bts-soft/mail-queue))
|
|
205
49
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
**Author:** Omar Sabry </br>
|
|
210
|
-
**Email:** [omar.sabry.dev@gmail.com](mailto:omar.sabry.dev@gmail.com "null") </br>
|
|
211
|
-
**LinkedIn:** [Omar Sabry | LinkedIn](https://www.linkedin.com/in/omarsa6ry/ "null") </br>
|
|
212
|
-
**Portfolio:** [Portfolio](https://omarsabry.netlify.app/ "null") </br>
|
|
213
|
-
|
|
214
|
-
## Repository
|
|
215
|
-
|
|
216
|
-
**GitHub:** [bts-soft/packages/core · Omar-Sa6ry/bts-soft](https://github.com/Omar-Sa6ry/bts-soft/tree/main/packages/core "null")
|
|
50
|
+
- [Config Documentation]([@bts-soft/mail-queue - npm](https://www.npmjs.com/package/@bts-soft/mail-queue))
|
|
51
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bts-soft/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"author": "Omar Sabry",
|
|
5
5
|
"description": "All bts-soft packages",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@bts-soft/mail-queue": "^1.0.5",
|
|
11
|
+
"@bts-soft/upload": "^1.1.1",
|
|
11
12
|
"@bts-soft/validation":"^1.0.0"
|
|
12
13
|
},
|
|
13
14
|
"peerDependencies": {
|