nesthub 1.0.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/README.md +108 -0
- package/dist/cache/README.md +91 -0
- package/dist/cache/index.d.ts +10 -0
- package/dist/cache/index.js +75 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/index.spec.d.ts +1 -0
- package/dist/cache/index.spec.js +61 -0
- package/dist/cache/index.spec.js.map +1 -0
- package/dist/excel/README.md +132 -0
- package/dist/excel/excel.module.d.ts +2 -0
- package/dist/excel/excel.module.js +21 -0
- package/dist/excel/excel.module.js.map +1 -0
- package/dist/excel/excel.service.d.ts +23 -0
- package/dist/excel/excel.service.js +124 -0
- package/dist/excel/excel.service.js.map +1 -0
- package/dist/excel/index.d.ts +2 -0
- package/dist/excel/index.js +8 -0
- package/dist/excel/index.js.map +1 -0
- package/dist/excel/interfaces.d.ts +19 -0
- package/dist/excel/interfaces.js +3 -0
- package/dist/excel/interfaces.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/index.spec.d.ts +1 -0
- package/dist/index.spec.js +11 -0
- package/dist/index.spec.js.map +1 -0
- package/dist/notification/README.md +237 -0
- package/dist/notification/channels/channel.interface.d.ts +10 -0
- package/dist/notification/channels/channel.interface.js +3 -0
- package/dist/notification/channels/channel.interface.js.map +1 -0
- package/dist/notification/channels/email.channel.d.ts +11 -0
- package/dist/notification/channels/email.channel.js +58 -0
- package/dist/notification/channels/email.channel.js.map +1 -0
- package/dist/notification/channels/firebase.channel.d.ts +11 -0
- package/dist/notification/channels/firebase.channel.js +69 -0
- package/dist/notification/channels/firebase.channel.js.map +1 -0
- package/dist/notification/channels/index.d.ts +5 -0
- package/dist/notification/channels/index.js +12 -0
- package/dist/notification/channels/index.js.map +1 -0
- package/dist/notification/channels/sms.channel.d.ts +8 -0
- package/dist/notification/channels/sms.channel.js +90 -0
- package/dist/notification/channels/sms.channel.js.map +1 -0
- package/dist/notification/channels/telegram.channel.d.ts +10 -0
- package/dist/notification/channels/telegram.channel.js +59 -0
- package/dist/notification/channels/telegram.channel.js.map +1 -0
- package/dist/notification/email/index.d.ts +62 -0
- package/dist/notification/email/index.js +253 -0
- package/dist/notification/email/index.js.map +1 -0
- package/dist/notification/email/index.spec.d.ts +1 -0
- package/dist/notification/email/index.spec.js +121 -0
- package/dist/notification/email/index.spec.js.map +1 -0
- package/dist/notification/entities/notification-log.entity.d.ts +15 -0
- package/dist/notification/entities/notification-log.entity.js +82 -0
- package/dist/notification/entities/notification-log.entity.js.map +1 -0
- package/dist/notification/firebase/index.d.ts +52 -0
- package/dist/notification/firebase/index.js +261 -0
- package/dist/notification/firebase/index.js.map +1 -0
- package/dist/notification/firebase/index.spec.d.ts +1 -0
- package/dist/notification/firebase/index.spec.js +114 -0
- package/dist/notification/firebase/index.spec.js.map +1 -0
- package/dist/notification/index.d.ts +12 -0
- package/dist/notification/index.js +26 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/notification/index.spec.d.ts +1 -0
- package/dist/notification/index.spec.js +336 -0
- package/dist/notification/index.spec.js.map +1 -0
- package/dist/notification/interfaces.d.ts +98 -0
- package/dist/notification/interfaces.js +3 -0
- package/dist/notification/interfaces.js.map +1 -0
- package/dist/notification/notification.constants.d.ts +4 -0
- package/dist/notification/notification.constants.js +8 -0
- package/dist/notification/notification.constants.js.map +1 -0
- package/dist/notification/notification.module.d.ts +10 -0
- package/dist/notification/notification.module.js +160 -0
- package/dist/notification/notification.module.js.map +1 -0
- package/dist/notification/notification.service.d.ts +14 -0
- package/dist/notification/notification.service.js +184 -0
- package/dist/notification/notification.service.js.map +1 -0
- package/dist/notification/queue/index.d.ts +2 -0
- package/dist/notification/queue/index.js +6 -0
- package/dist/notification/queue/index.js.map +1 -0
- package/dist/notification/queue/notification-queue.service.d.ts +31 -0
- package/dist/notification/queue/notification-queue.service.js +134 -0
- package/dist/notification/queue/notification-queue.service.js.map +1 -0
- package/dist/notification/services/index.d.ts +1 -0
- package/dist/notification/services/index.js +6 -0
- package/dist/notification/services/index.js.map +1 -0
- package/dist/notification/services/template.service.d.ts +13 -0
- package/dist/notification/services/template.service.js +75 -0
- package/dist/notification/services/template.service.js.map +1 -0
- package/dist/notification/shared.d.ts +48 -0
- package/dist/notification/shared.js +95 -0
- package/dist/notification/shared.js.map +1 -0
- package/dist/notification/sms/index.d.ts +52 -0
- package/dist/notification/sms/index.js +234 -0
- package/dist/notification/sms/index.js.map +1 -0
- package/dist/notification/sms/index.spec.d.ts +1 -0
- package/dist/notification/sms/index.spec.js +123 -0
- package/dist/notification/sms/index.spec.js.map +1 -0
- package/dist/notification/telegram/index.d.ts +50 -0
- package/dist/notification/telegram/index.js +248 -0
- package/dist/notification/telegram/index.js.map +1 -0
- package/dist/notification/telegram/index.spec.d.ts +1 -0
- package/dist/notification/telegram/index.spec.js +108 -0
- package/dist/notification/telegram/index.spec.js.map +1 -0
- package/dist/notification/typeorm-storage.d.ts +28 -0
- package/dist/notification/typeorm-storage.js +56 -0
- package/dist/notification/typeorm-storage.js.map +1 -0
- package/dist/notification/unified.d.ts +47 -0
- package/dist/notification/unified.js +207 -0
- package/dist/notification/unified.js.map +1 -0
- package/dist/queue/README.md +82 -0
- package/dist/queue/index.d.ts +14 -0
- package/dist/queue/index.js +17 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/index.spec.d.ts +1 -0
- package/dist/queue/index.spec.js +76 -0
- package/dist/queue/index.spec.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/typeorm/README.md +197 -0
- package/dist/typeorm/crud-controller.d.ts +4 -0
- package/dist/typeorm/crud-controller.js +81 -0
- package/dist/typeorm/crud-controller.js.map +1 -0
- package/dist/typeorm/crud-service.d.ts +6 -0
- package/dist/typeorm/crud-service.js +53 -0
- package/dist/typeorm/crud-service.js.map +1 -0
- package/dist/typeorm/crud.interface.d.ts +9 -0
- package/dist/typeorm/crud.interface.js +3 -0
- package/dist/typeorm/crud.interface.js.map +1 -0
- package/dist/typeorm/index.d.ts +23 -0
- package/dist/typeorm/index.js +66 -0
- package/dist/typeorm/index.js.map +1 -0
- package/dist/typeorm/index.spec.d.ts +1 -0
- package/dist/typeorm/index.spec.js +109 -0
- package/dist/typeorm/index.spec.js.map +1 -0
- package/package.json +229 -0
- package/src/cache/README.md +91 -0
- package/src/excel/README.md +132 -0
- package/src/notification/README.md +237 -0
- package/src/queue/README.md +82 -0
- package/src/typeorm/README.md +197 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# nesthub/queue
|
|
2
|
+
|
|
3
|
+
RDS-style config factory for [BullMQ](https://bullmq.io) (via `@nestjs/bullmq`).
|
|
4
|
+
|
|
5
|
+
Works with either Valkey (`VALKEY_URL`) or Redis (`REDIS_URL`) environment variables.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install nesthub @nestjs/bullmq bullmq
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { BullModule } from '@nestjs/bullmq';
|
|
17
|
+
import { configBullMQ } from 'nesthub/queue';
|
|
18
|
+
|
|
19
|
+
@Module({
|
|
20
|
+
imports: [
|
|
21
|
+
BullModule.forRootAsync({
|
|
22
|
+
useFactory: configBullMQ,
|
|
23
|
+
inject: [ConfigService],
|
|
24
|
+
}),
|
|
25
|
+
BullModule.registerQueue({ name: 'email' }),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
export class AppModule {}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Valkey (reads `VALKEY_URL` from env)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
BullModule.forRootAsync({
|
|
35
|
+
// Requires VALKEY_URL in .env:
|
|
36
|
+
// VALKEY_URL=valkey://localhost:6379
|
|
37
|
+
useFactory: configBullMQ,
|
|
38
|
+
inject: [ConfigService],
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Redis (reads `REDIS_URL` from env)
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
BullModule.forRootAsync({
|
|
46
|
+
useFactory: (config: ConfigService) =>
|
|
47
|
+
configBullMQ(config, { store: 'redis' }),
|
|
48
|
+
inject: [ConfigService],
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### With custom prefix and default job options
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
BullModule.forRootAsync({
|
|
56
|
+
useFactory: (config: ConfigService) =>
|
|
57
|
+
configBullMQ(config, {
|
|
58
|
+
prefix: '{myapp}',
|
|
59
|
+
defaultJobOptions: { attempts: 3, removeOnComplete: 100 },
|
|
60
|
+
}),
|
|
61
|
+
inject: [ConfigService],
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Direct URL (no env vars)
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
BullModule.forRootAsync({
|
|
69
|
+
useFactory: () => ({
|
|
70
|
+
connection: { url: 'redis://user:pass@host:6379' },
|
|
71
|
+
prefix: '{default}',
|
|
72
|
+
}),
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## QueueModuleOptions
|
|
77
|
+
|
|
78
|
+
| Option | Default | Description |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `store` | `'valkey'` | Backend store: `'valkey'` or `'redis'` |
|
|
81
|
+
| `prefix` | `'{default}'` | BullMQ key prefix |
|
|
82
|
+
| `defaultJobOptions` | — | Default job options for all queues (e.g. `{ attempts: 3 }`) |
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# nesthub/typeorm
|
|
2
|
+
|
|
3
|
+
TypeORM configuration helpers for cloud databases (RDS PostgreSQL / MySQL), plus CRUD service & controller factories.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install nesthub @nestjs/typeorm @nestjs/config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
The following environment variables must be declared in your `.env` file (or provided to `ConfigModule.forRoot()`):
|
|
14
|
+
|
|
15
|
+
| Variable | Required | Default |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `DB_HOST` | No | `localhost` |
|
|
18
|
+
| `DB_PORT` | No | `5432` (PG) / `3306` (MySQL) |
|
|
19
|
+
| `DB_USERNAME` | Yes | — |
|
|
20
|
+
| `DB_PASSWORD` | Yes | — |
|
|
21
|
+
| `DB_DATABASE` | No | `postgres` / `mysql` |
|
|
22
|
+
| `DB_SYNCHRONIZE` | No | `false` |
|
|
23
|
+
| `DB_LOGGING` | No | `false` |
|
|
24
|
+
| `DB_SSL_REJECT_UNAUTHORIZED` | No | `false` |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// app.module.ts
|
|
30
|
+
import { Module } from '@nestjs/common'
|
|
31
|
+
import { ConfigModule, ConfigService } from '@nestjs/config'
|
|
32
|
+
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
33
|
+
import { configTypeOrmRDSPostgres } from 'nesthub/typeorm'
|
|
34
|
+
|
|
35
|
+
@Module({
|
|
36
|
+
imports: [
|
|
37
|
+
ConfigModule.forRoot(),
|
|
38
|
+
TypeOrmModule.forRootAsync({
|
|
39
|
+
inject: [ConfigService],
|
|
40
|
+
useFactory: (config: ConfigService) =>
|
|
41
|
+
configTypeOrmRDSPostgres(config, {
|
|
42
|
+
poolSize: 20,
|
|
43
|
+
schema: 'public',
|
|
44
|
+
}),
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
})
|
|
48
|
+
export class AppModule {}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Environment variables
|
|
52
|
+
|
|
53
|
+
| Variable | Default | Type | Description |
|
|
54
|
+
|---|---|---|---|
|
|
55
|
+
| `DB_HOST` | `localhost` | `string` | Database host |
|
|
56
|
+
| `DB_PORT` | `5432` (PG) / `3306` (MySQL) | `number` | Connection port |
|
|
57
|
+
| `DB_USERNAME` | — | `string` | Database username |
|
|
58
|
+
| `DB_PASSWORD` | — | `string` | Database password |
|
|
59
|
+
| `DB_DATABASE` | `postgres` / `mysql` | `string` | Database name |
|
|
60
|
+
| `DB_SYNCHRONIZE` | `false` | `boolean` | Auto-sync schema (dev only) |
|
|
61
|
+
| `DB_LOGGING` | `false` | `boolean` | Enable query logging |
|
|
62
|
+
| `DB_SSL_REJECT_UNAUTHORIZED` | `false` | `boolean` | Reject unauthorized SSL certs |
|
|
63
|
+
|
|
64
|
+
## TypeOrmConfigOptions
|
|
65
|
+
|
|
66
|
+
| Option | Default | Description |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| `schema` | — | PostgreSQL schema (e.g. `public`) |
|
|
69
|
+
| `poolSize` | `20` (PG) / `10` (MySQL) | Maximum connections in pool |
|
|
70
|
+
| `idleTimeoutMs` | `30000` (PG) / `10000` (MySQL) | Max idle time before closing |
|
|
71
|
+
| `connectionTimeoutMs` | `10000` (PG) / `5000` (MySQL) | Connection timeout |
|
|
72
|
+
| `statementTimeoutMs` | `30000` (PG) | Query timeout |
|
|
73
|
+
|
|
74
|
+
## SSL — why both `ssl` and `extra.ssl`?
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
ssl: { rejectUnauthorized: false },
|
|
78
|
+
extra: {
|
|
79
|
+
ssl: { rejectUnauthorized: false },
|
|
80
|
+
// ...
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- **`ssl`** — tells TypeORM to configure the driver (`pg` / `mysql2`) with TLS
|
|
85
|
+
- **`extra.ssl`** — passes SSL config directly to the underlying driver pool
|
|
86
|
+
|
|
87
|
+
Cloud databases (AWS RDS, Google Cloud SQL, etc.) often use self-signed certificates, requiring `rejectUnauthorized: false` to trust them.
|
|
88
|
+
|
|
89
|
+
## Sample .env
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
DB_HOST=database-1.xxxxxx.us-east-1.rds.amazonaws.com
|
|
93
|
+
DB_PORT=5432
|
|
94
|
+
DB_USERNAME=postgres
|
|
95
|
+
DB_PASSWORD=my-secret-pw
|
|
96
|
+
DB_DATABASE=mydb
|
|
97
|
+
DB_SYNCHRONIZE=false
|
|
98
|
+
DB_LOGGING=true
|
|
99
|
+
DB_SSL_REJECT_UNAUTHORIZED=false
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## CRUD Service & Controller Factories
|
|
105
|
+
|
|
106
|
+
Generate ready-to-use CRUD service and controller classes for any TypeORM entity.
|
|
107
|
+
|
|
108
|
+
### `createCrudService(entity)`
|
|
109
|
+
|
|
110
|
+
Creates a base `@Injectable()` service class with `@InjectRepository(entity)` and standard CRUD methods (`findAll`, `findOne`, `create`, `update`, `remove`).
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Module } from '@nestjs/common'
|
|
114
|
+
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
115
|
+
import { createCrudService } from 'nesthub/typeorm'
|
|
116
|
+
import { User } from './user.entity'
|
|
117
|
+
|
|
118
|
+
const UserService = createCrudService(User)
|
|
119
|
+
|
|
120
|
+
@Module({
|
|
121
|
+
imports: [TypeOrmModule.forFeature([User])],
|
|
122
|
+
providers: [UserService],
|
|
123
|
+
})
|
|
124
|
+
export class UserModule {}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Extending
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { Injectable } from '@nestjs/common'
|
|
131
|
+
import { createCrudService } from 'nesthub/typeorm'
|
|
132
|
+
import { User } from './user.entity'
|
|
133
|
+
|
|
134
|
+
const BaseUserService = createCrudService(User)
|
|
135
|
+
|
|
136
|
+
@Injectable()
|
|
137
|
+
export class UserService extends BaseUserService {
|
|
138
|
+
async findByEmail(email: string) {
|
|
139
|
+
return this.repository.findOne({ where: { email } })
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `createCrudController(route, serviceClass)`
|
|
145
|
+
|
|
146
|
+
Creates a `@Controller()` class with REST endpoints (`GET /`, `GET /:id`, `POST /`, `PATCH /:id`, `DELETE /:id`) delegating to the given CRUD service.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { Module } from '@nestjs/common'
|
|
150
|
+
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
151
|
+
import {
|
|
152
|
+
createCrudService,
|
|
153
|
+
createCrudController,
|
|
154
|
+
} from 'nesthub/typeorm'
|
|
155
|
+
import { User } from './user.entity'
|
|
156
|
+
|
|
157
|
+
const UserService = createCrudService(User)
|
|
158
|
+
const UserController = createCrudController('users', UserService)
|
|
159
|
+
|
|
160
|
+
@Module({
|
|
161
|
+
imports: [TypeOrmModule.forFeature([User])],
|
|
162
|
+
controllers: [UserController],
|
|
163
|
+
providers: [UserService],
|
|
164
|
+
})
|
|
165
|
+
export class UserModule {}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `createCrudModule(entity, route)`
|
|
169
|
+
|
|
170
|
+
Convenience helper that returns both `service` and `controller` in one call.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { Module } from '@nestjs/common'
|
|
174
|
+
import { TypeOrmModule } from '@nestjs/typeorm'
|
|
175
|
+
import { createCrudModule } from 'nesthub/typeorm'
|
|
176
|
+
import { User } from './user.entity'
|
|
177
|
+
|
|
178
|
+
const { service: UserService, controller: UserController } =
|
|
179
|
+
createCrudModule(User, 'users')
|
|
180
|
+
|
|
181
|
+
@Module({
|
|
182
|
+
imports: [TypeOrmModule.forFeature([User])],
|
|
183
|
+
controllers: [UserController],
|
|
184
|
+
providers: [UserService],
|
|
185
|
+
})
|
|
186
|
+
export class UserModule {}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### API
|
|
190
|
+
|
|
191
|
+
| Method | Endpoint | Description |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `findAll` | `GET /` | List all records |
|
|
194
|
+
| `findOne` | `GET /:id` | Get one record by ID |
|
|
195
|
+
| `create` | `POST /` | Create a new record |
|
|
196
|
+
| `update` | `PATCH /:id` | Update an existing record |
|
|
197
|
+
| `remove` | `DELETE /:id` | Delete a record |
|