@bts-soft/core 1.0.0 → 1.0.1
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 +91 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
## @bts-soft/core | The BTS Software Core Toolkit
|
|
2
|
+
|
|
3
|
+
The **`@bts-soft/core`** package serves as the unified entry point for all high-quality, pre-configured modules developed by BTS Software.
|
|
4
|
+
|
|
5
|
+
This package simplifies development by bundling essential backend components (like email queuing, security guards, and utilities) into one dependency, ensuring a consistent and robust NestJS architecture out-of-the-box.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features and Included Modules
|
|
10
|
+
|
|
11
|
+
By installing `@bts-soft/core`, you automatically gain access to all the following specialized modules and services:
|
|
12
|
+
|
|
13
|
+
| Module | NPM Package (Internal) | Description |
|
|
14
|
+
| --------------- | ---------------------- | ---------------------------------------------------------------------------------------------- |
|
|
15
|
+
| **Email Queue** | `@bts-soft/mail-queue` | Reliable, asynchronous email sending using BullMQ and Nodemailer, preventing request blocking. |
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
### 1. Installation
|
|
23
|
+
|
|
24
|
+
Install the core package and its required peer dependencies (BullMQ, Nodemailer, etc. are installed automatically as dependencies of `@bts-soft/mail-queue`):
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npm install @bts-soft/core
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Configuration (Environment Variables)
|
|
32
|
+
|
|
33
|
+
Your application must define the following environment variables (required primarily by the `mail-queue` module):
|
|
34
|
+
|
|
35
|
+
|Variable|Usage|
|
|
36
|
+
|---|---|
|
|
37
|
+
|`REDIS_HOST`, `REDIS_PORT`|Required for BullMQ queue management.|
|
|
38
|
+
|`MAIL_HOST`, `MAIL_USER`, `MAIL_PASS`|Required for Nodemailer SMTP connection.|
|
|
39
|
+
|
|
40
|
+
### 3. Usage in `AppModule`
|
|
41
|
+
|
|
42
|
+
All modules are designed to be imported directly from the `@bts-soft/core` package.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
// app.module.ts
|
|
47
|
+
import { Module } from '@nestjs/common';
|
|
48
|
+
// Import all modules and services from the unified Core package
|
|
49
|
+
import { EmailModule } from '@bts-soft/core';
|
|
50
|
+
|
|
51
|
+
@Module({
|
|
52
|
+
imports: [
|
|
53
|
+
// Example: Registering the Email Module
|
|
54
|
+
EmailModule.register({
|
|
55
|
+
// Optional: Custom connection settings can be passed here
|
|
56
|
+
}),
|
|
57
|
+
// ... Other application modules
|
|
58
|
+
],
|
|
59
|
+
// ...
|
|
60
|
+
})
|
|
61
|
+
export class AppModule {}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. Injecting Services
|
|
65
|
+
|
|
66
|
+
Access services (like the email sender) by importing them directly from the core package:
|
|
67
|
+
|
|
68
|
+
TypeScript
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
// my.service.ts
|
|
72
|
+
import { Injectable } from '@nestjs/common';
|
|
73
|
+
import { SendEmailService } from '@bts-soft/core'; // ⬅️ Imported from @bts-soft/core
|
|
74
|
+
|
|
75
|
+
@Injectable()
|
|
76
|
+
export class MyService {
|
|
77
|
+
constructor(private readonly emailService: SendEmailService) {}
|
|
78
|
+
|
|
79
|
+
async handleSignup(user: any) {
|
|
80
|
+
// Logic...
|
|
81
|
+
|
|
82
|
+
// Queue the email job
|
|
83
|
+
await this.emailService.sendEmail(
|
|
84
|
+
user.email,
|
|
85
|
+
'Welcome!',
|
|
86
|
+
'Thanks for signing up to our platform.'
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bts-soft/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@bts-soft/mail-queue": "^1.0.
|
|
7
|
+
"@bts-soft/mail-queue": "^1.0.1"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"@nestjs/common": "^10.0.0",
|