@lyrolab/nest-shared 0.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/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc +5 -0
- package/README.md +98 -0
- package/dist/ai/ai.module.d.ts +2 -0
- package/dist/ai/ai.module.js +21 -0
- package/dist/ai/ai.module.js.map +1 -0
- package/dist/ai/services/ai.service.d.ts +10 -0
- package/dist/ai/services/ai.service.js +54 -0
- package/dist/ai/services/ai.service.js.map +1 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +21 -0
- package/dist/app.module.js.map +1 -0
- package/dist/bull/shared-bull.module.d.ts +4 -0
- package/dist/bull/shared-bull.module.js +40 -0
- package/dist/bull/shared-bull.module.js.map +1 -0
- package/dist/cache/shared-cache.module.d.ts +4 -0
- package/dist/cache/shared-cache.module.js +40 -0
- package/dist/cache/shared-cache.module.js.map +1 -0
- package/dist/database/filters/typeorm-exception.filter.d.ts +7 -0
- package/dist/database/filters/typeorm-exception.filter.js +35 -0
- package/dist/database/filters/typeorm-exception.filter.js.map +1 -0
- package/dist/database/shared-database.module.d.ts +18 -0
- package/dist/database/shared-database.module.js +119 -0
- package/dist/database/shared-database.module.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/queue/controllers/queue.controller.d.ts +7 -0
- package/dist/queue/controllers/queue.controller.js +40 -0
- package/dist/queue/controllers/queue.controller.js.map +1 -0
- package/dist/queue/decorators/queue.decorator.d.ts +1 -0
- package/dist/queue/decorators/queue.decorator.js +6 -0
- package/dist/queue/decorators/queue.decorator.js.map +1 -0
- package/dist/queue/models/dto/queue-add.dto.d.ts +4 -0
- package/dist/queue/models/dto/queue-add.dto.js +28 -0
- package/dist/queue/models/dto/queue-add.dto.js.map +1 -0
- package/dist/queue/models/job-processor-interface.d.ts +4 -0
- package/dist/queue/models/job-processor-interface.js +3 -0
- package/dist/queue/models/job-processor-interface.js.map +1 -0
- package/dist/queue/processors/queue.processor.d.ts +11 -0
- package/dist/queue/processors/queue.processor.js +63 -0
- package/dist/queue/processors/queue.processor.js.map +1 -0
- package/dist/queue/queue.constants.d.ts +1 -0
- package/dist/queue/queue.constants.js +5 -0
- package/dist/queue/queue.constants.js.map +1 -0
- package/dist/queue/queue.module.d.ts +2 -0
- package/dist/queue/queue.module.js +28 -0
- package/dist/queue/queue.module.js.map +1 -0
- package/dist/queue/services/queue.service.d.ts +6 -0
- package/dist/queue/services/queue.service.js +35 -0
- package/dist/queue/services/queue.service.js.map +1 -0
- package/dist/redis/redis.config.d.ts +4 -0
- package/dist/redis/redis.config.js +11 -0
- package/dist/redis/redis.config.js.map +1 -0
- package/dist/redis/shared-redis.module.d.ts +9 -0
- package/dist/redis/shared-redis.module.js +68 -0
- package/dist/redis/shared-redis.module.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/eslint.config.mjs +35 -0
- package/nest-cli.json +9 -0
- package/package.json +126 -0
- package/src/ai/ai.module.ts +8 -0
- package/src/ai/services/ai.service.ts +51 -0
- package/src/app.module.ts +8 -0
- package/src/bull/shared-bull.module.ts +27 -0
- package/src/cache/shared-cache.module.ts +30 -0
- package/src/database/filters/typeorm-exception.filter.ts +35 -0
- package/src/database/shared-database.module.ts +136 -0
- package/src/index.ts +12 -0
- package/src/queue/controllers/queue.controller.ts +13 -0
- package/src/queue/decorators/queue.decorator.ts +3 -0
- package/src/queue/models/dto/queue-add.dto.ts +10 -0
- package/src/queue/models/job-processor-interface.ts +5 -0
- package/src/queue/processors/queue.processor.ts +53 -0
- package/src/queue/queue.constants.ts +1 -0
- package/src/queue/queue.module.ts +14 -0
- package/src/queue/services/queue.service.ts +17 -0
- package/src/redis/redis.config.ts +3 -0
- package/src/redis/shared-redis.module.ts +66 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DynamicModule, Module, OnModuleDestroy } from "@nestjs/common"
|
|
2
|
+
import { ConfigModule, ConfigService } from "@nestjs/config"
|
|
3
|
+
import { GenericContainer, StartedTestContainer, Wait } from "testcontainers"
|
|
4
|
+
import { RedisConfig } from "./redis.config"
|
|
5
|
+
|
|
6
|
+
@Module({})
|
|
7
|
+
export class SharedRedisModule implements OnModuleDestroy {
|
|
8
|
+
private static testContainer: StartedTestContainer | null = null
|
|
9
|
+
|
|
10
|
+
static forRoot(): DynamicModule {
|
|
11
|
+
return {
|
|
12
|
+
module: SharedRedisModule,
|
|
13
|
+
providers: [
|
|
14
|
+
{
|
|
15
|
+
provide: RedisConfig,
|
|
16
|
+
useFactory: async (configService: ConfigService) => {
|
|
17
|
+
const isTestEnvironment = process.env.NODE_ENV === "test"
|
|
18
|
+
|
|
19
|
+
if (isTestEnvironment) {
|
|
20
|
+
return new RedisConfig(await this.createTestConfiguration())
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new RedisConfig(
|
|
24
|
+
this.createProductionConfiguration(configService),
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
inject: [ConfigService],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
exports: [RedisConfig],
|
|
31
|
+
imports: [ConfigModule],
|
|
32
|
+
global: true,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static async createTestConfiguration() {
|
|
37
|
+
if (!this.testContainer) {
|
|
38
|
+
this.testContainer = await new GenericContainer("redis")
|
|
39
|
+
.withExposedPorts(6379)
|
|
40
|
+
.withWaitStrategy(
|
|
41
|
+
Wait.forAll([
|
|
42
|
+
Wait.forListeningPorts(),
|
|
43
|
+
Wait.forLogMessage("Ready to accept connections tcp"),
|
|
44
|
+
]),
|
|
45
|
+
)
|
|
46
|
+
.start()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return `redis://${this.testContainer.getHost()}:${this.testContainer.getMappedPort(6379)}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private static createProductionConfiguration(configService: ConfigService) {
|
|
53
|
+
return configService.get("REDIS_URL") as string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static async closeTestConnection(): Promise<void> {
|
|
57
|
+
if (this.testContainer) {
|
|
58
|
+
await this.testContainer.stop()
|
|
59
|
+
this.testContainer = null
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async onModuleDestroy() {
|
|
64
|
+
await SharedRedisModule.closeTestConnection()
|
|
65
|
+
}
|
|
66
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "ES2023",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strictNullChecks": true,
|
|
16
|
+
"forceConsistentCasingInFileNames": true,
|
|
17
|
+
"noImplicitAny": true,
|
|
18
|
+
"strictBindCallApply": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"paths": {
|
|
21
|
+
"@app/nest-shared": ["libs/nest-shared/src"],
|
|
22
|
+
"@app/nest-shared/*": ["libs/nest-shared/src/*"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|