nesthub 1.0.2 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nesthub",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "All-in-one modular toolkit for NestJS",
5
5
  "keywords": [
6
6
  "nestjs",
@@ -16,7 +16,12 @@
16
16
  "telegram",
17
17
  "sms",
18
18
  "email",
19
- "crud"
19
+ "crud",
20
+ "swagger",
21
+ "scalar",
22
+ "api-docs",
23
+ "api-reference",
24
+ "excel"
20
25
  ],
21
26
  "author": "Wind Blade <vn.chemgio@yahoo.com> (https://github.com/Vn-ChemGio)",
22
27
  "funding": {
@@ -68,6 +73,11 @@
68
73
  "types": "./dist/excel/index.d.ts",
69
74
  "import": "./dist/excel/index.js",
70
75
  "require": "./dist/excel/index.js"
76
+ },
77
+ "./swagger": {
78
+ "types": "./dist/swagger/index.d.ts",
79
+ "import": "./dist/swagger/index.js",
80
+ "require": "./dist/swagger/index.js"
71
81
  }
72
82
  },
73
83
  "typesVersions": {
@@ -86,6 +96,9 @@
86
96
  ],
87
97
  "excel": [
88
98
  "./dist/excel/index.d.ts"
99
+ ],
100
+ "swagger": [
101
+ "./dist/swagger/index.d.ts"
89
102
  ]
90
103
  }
91
104
  },
@@ -101,10 +114,11 @@
101
114
  "src/cache/README.md",
102
115
  "src/queue/README.md",
103
116
  "src/notification/README.md",
104
- "src/excel/README.md"
117
+ "src/excel/README.md",
118
+ "src/swagger/README.md"
105
119
  ],
106
120
  "scripts": {
107
- "build": "tsc -p tsconfig.build.json && node -e \"require('fs').copyFileSync('src/typeorm/README.md','dist/typeorm/README.md');require('fs').copyFileSync('src/cache/README.md','dist/cache/README.md');require('fs').copyFileSync('src/queue/README.md','dist/queue/README.md');require('fs').copyFileSync('src/notification/README.md','dist/notification/README.md');require('fs').copyFileSync('src/excel/README.md','dist/excel/README.md')\"",
121
+ "build": "tsc -p tsconfig.build.json && node -e \"require('fs').copyFileSync('src/typeorm/README.md','dist/typeorm/README.md');require('fs').copyFileSync('src/cache/README.md','dist/cache/README.md');require('fs').copyFileSync('src/queue/README.md','dist/queue/README.md');require('fs').copyFileSync('src/notification/README.md','dist/notification/README.md');require('fs').copyFileSync('src/excel/README.md','dist/excel/README.md');require('fs').copyFileSync('src/swagger/README.md','dist/swagger/README.md')\"",
108
122
  "clean": "rimraf dist",
109
123
  "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
110
124
  "lint": "eslint \"{src,test}/**/*.ts\" --fix",
@@ -122,7 +136,10 @@
122
136
  "@nestjs/common": "^11.0.1",
123
137
  "@nestjs/config": "^4.0.4",
124
138
  "@nestjs/core": "^11.0.1",
139
+ "@nestjs/swagger": "^11.0.0",
125
140
  "@nestjs/typeorm": "^11.0.1",
141
+ "@scalar/api-reference": "^1.60.0",
142
+ "@scalar/nestjs-api-reference": "^1.0.0",
126
143
  "bullmq": "^5.44.0",
127
144
  "exceljs": "^4.4.0",
128
145
  "firebase-admin": "^13.0.2",
@@ -167,6 +184,12 @@
167
184
  },
168
185
  "exceljs": {
169
186
  "optional": true
187
+ },
188
+ "@nestjs/swagger": {
189
+ "optional": true
190
+ },
191
+ "@scalar/nestjs-api-reference": {
192
+ "optional": true
170
193
  }
171
194
  },
172
195
  "dependencies": {
@@ -184,8 +207,10 @@
184
207
  "@nestjs/common": "^11.0.1",
185
208
  "@nestjs/config": "^4.0.4",
186
209
  "@nestjs/core": "^11.0.1",
210
+ "@nestjs/swagger": "^11.0.0",
187
211
  "@nestjs/testing": "^11.0.1",
188
212
  "@nestjs/typeorm": "^11.0.1",
213
+ "@scalar/nestjs-api-reference": "^1.0.0",
189
214
  "@types/jest": "^30.0.0",
190
215
  "@types/node": "^24.0.0",
191
216
  "bullmq": "^5.44.0",
@@ -215,7 +240,12 @@
215
240
  "rootDir": "src",
216
241
  "testRegex": ".*\\.spec\\.ts$",
217
242
  "transform": {
218
- "^.+\\.(t|j)s$": "ts-jest"
243
+ "^.+\\.(t|j)s$": [
244
+ "ts-jest",
245
+ {
246
+ "tsconfig": "tsconfig.test.json"
247
+ }
248
+ ]
219
249
  },
220
250
  "moduleNameMapper": {
221
251
  "^(\\.{1,2}/.*)\\.js$": "$1"
@@ -235,3 +235,56 @@ export class AppModule {}
235
235
  | `createdAt` | `created_at` |
236
236
  | `updatedAt` | `updated_at` |
237
237
  | `sentAt` | `sent_at` |
238
+
239
+ ## Telegram Channel
240
+
241
+ ### Configuration
242
+
243
+ ```typescript
244
+ channels: {
245
+ telegram: { botToken: '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11' },
246
+ }
247
+ ```
248
+
249
+ ### Sending messages
250
+
251
+ **Text only** — sends via `/sendMessage`:
252
+ ```typescript
253
+ await notification.send({
254
+ channel: 'telegram',
255
+ to: '1077316390',
256
+ content: '<b>Hello</b> from HTML',
257
+ });
258
+ ```
259
+
260
+ **With file attachment** — sends via `/sendDocument`, `content` becomes the caption:
261
+ ```typescript
262
+ await notification.send({
263
+ channel: 'telegram',
264
+ to: '1077316390',
265
+ content: 'Report attached',
266
+ attachments: [{ filename: 'report.xlsx', content: buffer }],
267
+ });
268
+ ```
269
+
270
+ **Multiple files** — sends via `/sendMediaGroup` (single request), caption on last file:
271
+ ```typescript
272
+ await notification.send({
273
+ channel: 'telegram',
274
+ to: '1077316390',
275
+ content: 'Monthly reports',
276
+ attachments: [
277
+ { filename: 'jan.xlsx', content: buf1 },
278
+ { filename: 'feb.xlsx', content: buf2 },
279
+ ],
280
+ });
281
+ ```
282
+
283
+ **Attachment from file path:**
284
+ ```typescript
285
+ await notification.send({
286
+ channel: 'telegram',
287
+ to: '1077316390',
288
+ attachments: [{ filename: 'photo.jpg', path: '/tmp/photo.jpg' }],
289
+ });
290
+ ```
@@ -0,0 +1,53 @@
1
+ # @nesthub/swagger
2
+
3
+ Scalar API reference for NestJS — powered by `@scalar/nestjs-api-reference`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @nestjs/swagger @scalar/nestjs-api-reference
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { NestFactory } from '@nestjs/core';
15
+ import { setupSwaggerUI } from 'nesthub/swagger';
16
+ import { AppModule } from './app.module';
17
+
18
+ async function bootstrap() {
19
+ const app = await NestFactory.create(AppModule);
20
+
21
+ setupSwaggerUI(app, {
22
+ title: 'My API',
23
+ description: 'API documentation',
24
+ version: '1.0.0',
25
+ persistAuth: true,
26
+ serverUrl: 'http://localhost:3000',
27
+ });
28
+
29
+ await app.listen(3000);
30
+ }
31
+ ```
32
+
33
+ ## Options
34
+
35
+ | Option | Type | Default | Description |
36
+ |--------|------|---------|-------------|
37
+ | `path` | `string` | `'api-docs'` | Path to serve Scalar |
38
+ | `title` | `string` | `'API Documentation'` | API title |
39
+ | `description` | `string` | `''` | API description |
40
+ | `version` | `string` | `'1.0'` | API version |
41
+ | `persistAuth` | `boolean` | `false` | Persist auth in localStorage |
42
+ | `serverUrl` | `string` | `undefined` | Server URL |
43
+ | `serverDescription` | `string` | `undefined` | Server description |
44
+
45
+ ## Content Security Policy
46
+
47
+ Scalar loads UI assets from `https://cdn.jsdelivr.net` and uses inline scripts. If your app sets a `Content-Security-Policy` header, update `script-src` to allow:
48
+
49
+ ```http
50
+ Content-Security-Policy: script-src 'self' https://cdn.jsdelivr.net 'unsafe-inline'; style-src 'self' 'unsafe-inline'
51
+ ```
52
+
53
+ For stricter security, use a nonce or hash (the hash changes per Scalar version — generate it from the inline script content or pin a specific version).