- Introduced new SIM management queue and processor to handle SIM-related tasks efficiently. - Added SIM activation fee handling in the checkout service, ensuring proper validation and inclusion in cart calculations. - Enhanced the SimCatalogService to retrieve and filter activation fees based on SKU, improving order validation. - Updated the checkout process to automatically add default activation fees when none are specified, improving user experience. - Refactored the ActivationForm component to display activation fees clearly during the SIM configuration process. - Improved error handling and logging across various services to provide better insights during operations. - Updated tests to cover new features and ensure reliability in the checkout and SIM management workflows.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { Global, Module } from "@nestjs/common";
|
|
import { BullModule } from "@nestjs/bullmq";
|
|
import { ConfigModule, ConfigService } from "@nestjs/config";
|
|
import { QUEUE_NAMES } from "./queue.constants";
|
|
|
|
function parseRedisConnection(redisUrl: string) {
|
|
try {
|
|
const url = new URL(redisUrl);
|
|
const isTls = url.protocol === "rediss:";
|
|
const db = url.pathname && url.pathname !== "/" ? Number(url.pathname.slice(1)) : undefined;
|
|
return {
|
|
host: url.hostname,
|
|
port: Number(url.port || (isTls ? 6380 : 6379)),
|
|
password: url.password || undefined,
|
|
...(db !== undefined ? { db } : {}),
|
|
...(isTls ? { tls: {} } : {}),
|
|
} as Record<string, unknown>;
|
|
} catch {
|
|
return { host: "localhost", port: 6379 } as Record<string, unknown>;
|
|
}
|
|
}
|
|
|
|
@Global()
|
|
@Module({
|
|
imports: [
|
|
ConfigModule,
|
|
BullModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
connection: parseRedisConnection(config.get<string>("REDIS_URL", "redis://localhost:6379")),
|
|
}),
|
|
}),
|
|
BullModule.registerQueue(
|
|
{ name: QUEUE_NAMES.EMAIL },
|
|
{ name: QUEUE_NAMES.PROVISIONING },
|
|
{ name: QUEUE_NAMES.RECONCILE },
|
|
{ name: QUEUE_NAMES.SIM_MANAGEMENT }
|
|
),
|
|
],
|
|
exports: [BullModule],
|
|
})
|
|
export class QueueModule {}
|