@bts-soft/core 2.4.7 → 2.4.8
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 +96 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @bts-soft/core
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
3
8
|
## The Definitive Enterprise Meta-Framework for NestJS
|
|
4
9
|
|
|
5
10
|
`@bts-soft/core` is not just a package; it is the architectural backbone of the BTS Soft enterprise ecosystem. It streamlines the development of high-performance, secure, and scalable NestJS applications by consolidating five specialized packages into a unified, high-level API.
|
|
@@ -8,6 +13,82 @@ This documentation serves as the comprehensive technical manual for the entire c
|
|
|
8
13
|
|
|
9
14
|
---
|
|
10
15
|
|
|
16
|
+
## Table of Contents
|
|
17
|
+
- [Installation \& Quick Start](#installation--quick-start)
|
|
18
|
+
- [Core Vision \& Architecture](#core-vision--architecture)
|
|
19
|
+
- [Module Index](#module-index)
|
|
20
|
+
- [Deep Dive: @bts-soft/validation](#deep-dive-bts-softvalidation)
|
|
21
|
+
- [Deep Dive: @bts-soft/cache](#deep-dive-bts-softcache)
|
|
22
|
+
- [Deep Dive: @bts-soft/notifications](#deep-dive-bts-softnotifications)
|
|
23
|
+
- [Deep Dive: @bts-soft/upload](#deep-dive-bts-softupload)
|
|
24
|
+
- [Deep Dive: @bts-soft/common](#deep-dive-bts-softcommon)
|
|
25
|
+
- [Security Audit \& Hardening Guide](#security-audit--hardening-guide)
|
|
26
|
+
- [Deployment, CI/CD, and Operations](#deployment-cicd-and-operations)
|
|
27
|
+
- [The Giant Book of Usage Examples](#the-giant-book-of-usage-examples)
|
|
28
|
+
- [Frequently Asked Questions (FAQ)](#frequently-asked-questions-faq)
|
|
29
|
+
- [Exhaustive Redis API Guide](#exhaustive-redis-api-guide)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation & Quick Start
|
|
34
|
+
|
|
35
|
+
### 1. Install the Package
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @bts-soft/core
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
*Note: `@bts-soft/core` requires `Node.js >= 20.17.0` and has peer dependencies on `@nestjs/common` and `@nestjs/core` (v11+).*
|
|
42
|
+
|
|
43
|
+
### 2. Basic Integration
|
|
44
|
+
|
|
45
|
+
Import the individual modules provided by `@bts-soft/core` into your `AppModule` or use them as needed:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { Module } from '@nestjs/common';
|
|
49
|
+
import {
|
|
50
|
+
ConfigModule,
|
|
51
|
+
GraphqlModule,
|
|
52
|
+
ThrottlingModule
|
|
53
|
+
} from '@bts-soft/core';
|
|
54
|
+
|
|
55
|
+
@Module({
|
|
56
|
+
imports: [
|
|
57
|
+
ConfigModule,
|
|
58
|
+
ThrottlingModule,
|
|
59
|
+
GraphqlModule,
|
|
60
|
+
// Add other core modules like RedisModule, UploadModule, etc. as needed
|
|
61
|
+
],
|
|
62
|
+
})
|
|
63
|
+
export class AppModule {}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Bootstrap Utilities
|
|
67
|
+
|
|
68
|
+
In your `main.ts`, utilize the core infrastructure to set up global interceptors and launch banners:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { NestFactory } from '@nestjs/core';
|
|
72
|
+
import { AppModule } from './app.module';
|
|
73
|
+
import { setupInterceptors, displayAppBanner } from '@bts-soft/core';
|
|
74
|
+
|
|
75
|
+
async function bootstrap() {
|
|
76
|
+
const app = await NestFactory.create(AppModule);
|
|
77
|
+
|
|
78
|
+
// Apply standard BTS-Soft global interceptors (Serialization, SQLi Protection, Formatting)
|
|
79
|
+
setupInterceptors(app);
|
|
80
|
+
|
|
81
|
+
const port = process.env.PORT || 3000;
|
|
82
|
+
await app.listen(port);
|
|
83
|
+
|
|
84
|
+
// Display the professional terminal banner
|
|
85
|
+
displayAppBanner('My Service', port);
|
|
86
|
+
}
|
|
87
|
+
bootstrap();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
11
92
|
## Core Vision & Architecture
|
|
12
93
|
|
|
13
94
|
The primary objective of `@bts-soft/core` is to eliminate "infrastructure boilerplate." Instead of configuring Redis, Cloudinary, BullMQ, and Nodemailer repeatedly for every microservice, developers can import a single module that provides pre-validated, secure, and performant implementations of these essential services.
|
|
@@ -348,6 +429,15 @@ The common package provides pre-configured NestJS modules:
|
|
|
348
429
|
|
|
349
430
|
---
|
|
350
431
|
|
|
432
|
+
### Production & CLI Utilities
|
|
433
|
+
|
|
434
|
+
The common package exposes tools to manage environment-specific behaviors:
|
|
435
|
+
|
|
436
|
+
- **`disableConsoleInProduction()`**: A safety utility to mute all `console` outputs when running in production.
|
|
437
|
+
- **`displayAppBanner(appName, port)`**: Displays a clean, professional banner in the terminal when the server starts.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
351
441
|
|
|
352
442
|
---
|
|
353
443
|
|
|
@@ -506,6 +596,12 @@ The Upload module provides:
|
|
|
506
596
|
- Size caps to prevent Disk Exhaustion attacks.
|
|
507
597
|
- Strategy-level validation to ensure the cloud provider is reputable and secure.
|
|
508
598
|
|
|
599
|
+
### 5. Production Optimization & Information Leakage Prevention
|
|
600
|
+
|
|
601
|
+
To prevent sensitive data from leaking into server logs (such as tokens, passwords, or PII mistakenly logged during development), the `@bts-soft/core` meta-package **automatically disables all `console.*` methods** (e.g., `console.log`, `console.error`) the moment it is imported, provided that `process.env.NODE_ENV === "production"`.
|
|
602
|
+
|
|
603
|
+
If your production environment requires structured logging, you should use the NestJS `Logger` class or a dedicated logging transport instead of native `console` methods.
|
|
604
|
+
|
|
509
605
|
---
|
|
510
606
|
|
|
511
607
|
## Deployment, CI/CD, and Operations
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "@bts-soft/notifications";
|
|
2
|
+
export * from "@bts-soft/cache";
|
|
3
|
+
export * from "@bts-soft/upload";
|
|
4
|
+
export * from "@bts-soft/validation";
|
|
5
|
+
export * from "@bts-soft/common";
|
package/dist/index.js
CHANGED
|
@@ -19,4 +19,12 @@ __exportStar(require("@bts-soft/cache"), exports);
|
|
|
19
19
|
__exportStar(require("@bts-soft/upload"), exports);
|
|
20
20
|
__exportStar(require("@bts-soft/validation"), exports);
|
|
21
21
|
__exportStar(require("@bts-soft/common"), exports);
|
|
22
|
+
if (process.env.NODE_ENV === "production") {
|
|
23
|
+
const noop = () => { };
|
|
24
|
+
console.log = noop;
|
|
25
|
+
console.error = noop;
|
|
26
|
+
console.warn = noop;
|
|
27
|
+
console.info = noop;
|
|
28
|
+
console.debug = noop;
|
|
29
|
+
}
|
|
22
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,0DAAwC;AAGxC,kDAAgC;AAGhC,mDAAiC;AAGjC,uDAAqC;AAGrC,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,0DAAwC;AAGxC,kDAAgC;AAGhC,mDAAiC;AAGjC,uDAAqC;AAGrC,mDAAiC;AAEjC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;AACvB,CAAC"}
|