From 7243d4f158f8e69c12284234d49dbe18af04a52c Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Thu, 27 Jun 2024 20:13:22 +0530 Subject: [PATCH 1/3] feat: implement multi support nats client Signed-off-by: bhavanakarwade --- .../src/agent-provisioning.module.ts | 3 +- apps/agent-provisioning/src/main.ts | 3 +- .../agent-service/src/agent-service.module.ts | 3 +- apps/agent-service/src/main.ts | 2 +- .../src/agent-service/agent-service.module.ts | 3 +- apps/api-gateway/src/app.module.ts | 3 +- apps/api-gateway/src/authz/authz.module.ts | 3 +- .../src/connection/connection.module.ts | 3 +- .../credential-definition.module.ts | 3 +- .../src/ecosystem/ecosystem.module.ts | 3 +- apps/api-gateway/src/fido/fido.module.ts | 3 +- .../src/issuance/issuance.module.ts | 3 +- apps/api-gateway/src/main.ts | 4 +- .../src/notification/notification.module.ts | 3 +- .../src/organization/organization.module.ts | 4 +- .../src/platform/platform.module.ts | 3 +- apps/api-gateway/src/schema/schema.module.ts | 3 +- apps/api-gateway/src/user/user.module.ts | 3 +- .../src/utilities/utilities.module.ts | 3 +- .../src/verification/verification.module.ts | 3 +- .../api-gateway/src/webhook/webhook.module.ts | 3 +- apps/connection/src/connection.module.ts | 3 +- apps/connection/src/main.ts | 3 +- apps/ecosystem/src/ecosystem.module.ts | 3 +- apps/ecosystem/src/main.ts | 3 +- apps/issuance/src/issuance.module.ts | 3 +- apps/issuance/src/main.ts | 3 +- .../credential-definition.module.ts | 4 +- apps/ledger/src/ledger.module.ts | 3 +- apps/ledger/src/main.ts | 4 +- apps/ledger/src/schema/schema.module.ts | 4 +- apps/notification/src/main.ts | 3 +- apps/notification/src/notification.module.ts | 3 +- apps/organization/src/main.ts | 3 +- apps/organization/src/organization.module.ts | 3 +- apps/user/src/main.ts | 3 +- apps/user/src/user.module.ts | 3 +- apps/utility/src/main.ts | 3 +- apps/utility/src/utilities.module.ts | 3 +- apps/verification/src/main.ts | 3 +- apps/verification/src/verification.module.ts | 4 +- apps/webhook/src/main.ts | 3 +- apps/webhook/src/webhook.module.ts | 3 +- libs/common/src/common.constant.ts | 45 +++++++++++++------ libs/common/src/nats.config.ts | 29 +++++++++--- libs/enum/src/enum.ts | 5 +++ 46 files changed, 148 insertions(+), 65 deletions(-) diff --git a/apps/agent-provisioning/src/agent-provisioning.module.ts b/apps/agent-provisioning/src/agent-provisioning.module.ts index ba467e06d..c088be39f 100644 --- a/apps/agent-provisioning/src/agent-provisioning.module.ts +++ b/apps/agent-provisioning/src/agent-provisioning.module.ts @@ -4,6 +4,7 @@ import { AgentProvisioningService } from './agent-provisioning.service'; import { ClientsModule, Transport } from '@nestjs/microservices'; import { ConfigModule } from '@nestjs/config'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ ConfigModule.forRoot(), @@ -11,7 +12,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.AGENT_PROVISIONING_NKEY_SEED) + options: getNatsOptions(CommonConstants.AGENT_PROVISIONING, process.env.AGENT_PROVISIONING_NKEY_SEED) } ]) diff --git a/apps/agent-provisioning/src/main.ts b/apps/agent-provisioning/src/main.ts index f0c623640..4002bc54c 100644 --- a/apps/agent-provisioning/src/main.ts +++ b/apps/agent-provisioning/src/main.ts @@ -4,13 +4,14 @@ import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { AgentProvisioningModule } from './agent-provisioning.module'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(AgentProvisioningModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.AGENT_PROVISIONING_NKEY_SEED) + options: getNatsOptions(CommonConstants.AGENT_PROVISIONING, process.env.AGENT_PROVISIONING_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/agent-service/src/agent-service.module.ts b/apps/agent-service/src/agent-service.module.ts index 87bcb642a..c9bbbc566 100644 --- a/apps/agent-service/src/agent-service.module.ts +++ b/apps/agent-service/src/agent-service.module.ts @@ -10,6 +10,7 @@ import { ConnectionService } from 'apps/connection/src/connection.service'; import { ConnectionRepository } from 'apps/connection/src/connection.repository'; import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -18,7 +19,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.AGENT_SERVICE_NKEY_SEED) + options: getNatsOptions(CommonConstants.AGENT_SERVICE, process.env.AGENT_SERVICE_NKEY_SEED) } ]), CommonModule, diff --git a/apps/agent-service/src/main.ts b/apps/agent-service/src/main.ts index efafbfbc4..8b8b7441f 100644 --- a/apps/agent-service/src/main.ts +++ b/apps/agent-service/src/main.ts @@ -15,7 +15,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(AgentServiceModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.AGENT_SERVICE_NKEY_SEED) + options: getNatsOptions(CommonConstants.AGENT_SERVICE, process.env.AGENT_SERVICE_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/api-gateway/src/agent-service/agent-service.module.ts b/apps/api-gateway/src/agent-service/agent-service.module.ts index 0c3484cc7..0d24cd9da 100644 --- a/apps/api-gateway/src/agent-service/agent-service.module.ts +++ b/apps/api-gateway/src/agent-service/agent-service.module.ts @@ -7,6 +7,7 @@ import { ConfigModule } from '@nestjs/config'; import { AgentController } from './agent-service.controller'; import { AgentService } from './agent-service.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.AGENT_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule diff --git a/apps/api-gateway/src/app.module.ts b/apps/api-gateway/src/app.module.ts index 8b853a00e..33598731b 100644 --- a/apps/api-gateway/src/app.module.ts +++ b/apps/api-gateway/src/app.module.ts @@ -27,6 +27,7 @@ import * as redisStore from 'cache-manager-redis-store'; import { WebhookModule } from './webhook/webhook.module'; import { UtilitiesModule } from './utilities/utilities.module'; import { NotificationModule } from './notification/notification.module'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -35,7 +36,7 @@ import { NotificationModule } from './notification/notification.module'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.API_GATEWAY_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]), AgentModule, diff --git a/apps/api-gateway/src/authz/authz.module.ts b/apps/api-gateway/src/authz/authz.module.ts index 7c1a03779..bcaca9b44 100644 --- a/apps/api-gateway/src/authz/authz.module.ts +++ b/apps/api-gateway/src/authz/authz.module.ts @@ -19,6 +19,7 @@ import { VerificationService } from '../verification/verification.service'; import { EcosystemService } from '../ecosystem/ecosystem.service'; import { getNatsOptions } from '@credebl/common/nats.config'; import { OrganizationService } from '../organization/organization.service'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -31,7 +32,7 @@ import { OrganizationService } from '../organization/organization.service'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.AUTH_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule ]), diff --git a/apps/api-gateway/src/connection/connection.module.ts b/apps/api-gateway/src/connection/connection.module.ts index bc2b5be51..f8047bfd3 100644 --- a/apps/api-gateway/src/connection/connection.module.ts +++ b/apps/api-gateway/src/connection/connection.module.ts @@ -3,6 +3,7 @@ import { ConnectionController } from './connection.controller'; import { ConnectionService } from './connection.service'; import { Module } from '@nestjs/common'; import { ClientsModule, Transport } from '@nestjs/microservices'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -11,7 +12,7 @@ import { ClientsModule, Transport } from '@nestjs/microservices'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.CONNECTION_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/api-gateway/src/credential-definition/credential-definition.module.ts b/apps/api-gateway/src/credential-definition/credential-definition.module.ts index f7c2ac8a3..769b72109 100644 --- a/apps/api-gateway/src/credential-definition/credential-definition.module.ts +++ b/apps/api-gateway/src/credential-definition/credential-definition.module.ts @@ -4,6 +4,7 @@ import { Logger, Module } from '@nestjs/common'; import { CredentialDefinitionController } from './credential-definition.controller'; import { CredentialDefinitionService } from './credential-definition.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports:[ @@ -11,7 +12,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.CREDENTIAL_DEFINITION_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/api-gateway/src/ecosystem/ecosystem.module.ts b/apps/api-gateway/src/ecosystem/ecosystem.module.ts index 91146eb15..1a25f8ea0 100644 --- a/apps/api-gateway/src/ecosystem/ecosystem.module.ts +++ b/apps/api-gateway/src/ecosystem/ecosystem.module.ts @@ -7,6 +7,7 @@ import { Module } from '@nestjs/common'; import { EcosystemController } from './ecosystem.controller'; import { EcosystemService } from './ecosystem.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.ECOSYSTEM_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule ]) diff --git a/apps/api-gateway/src/fido/fido.module.ts b/apps/api-gateway/src/fido/fido.module.ts index e6bd502f9..7805e7cbb 100644 --- a/apps/api-gateway/src/fido/fido.module.ts +++ b/apps/api-gateway/src/fido/fido.module.ts @@ -3,6 +3,7 @@ import { ClientsModule, Transport } from '@nestjs/microservices'; import { FidoController } from './fido.controller'; import { FidoService } from './fido.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports:[ @@ -10,7 +11,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.FIDO_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) diff --git a/apps/api-gateway/src/issuance/issuance.module.ts b/apps/api-gateway/src/issuance/issuance.module.ts index ffec09e8b..ff92a8c87 100644 --- a/apps/api-gateway/src/issuance/issuance.module.ts +++ b/apps/api-gateway/src/issuance/issuance.module.ts @@ -7,6 +7,7 @@ import { HttpModule } from '@nestjs/axios'; import { getNatsOptions } from '@credebl/common/nats.config'; import { ImageServiceService } from '@credebl/image-service'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -15,7 +16,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.ISSUANCE_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/api-gateway/src/main.ts b/apps/api-gateway/src/main.ts index aafe38b14..c8fc3aa08 100644 --- a/apps/api-gateway/src/main.ts +++ b/apps/api-gateway/src/main.ts @@ -9,9 +9,9 @@ import { HttpAdapterHost, NestFactory } from '@nestjs/core'; import { AllExceptionsFilter } from '@credebl/common/exception-handler'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; - import helmet from 'helmet'; import { NodeEnvironment } from '@credebl/enum/enum'; +import { CommonConstants } from '@credebl/common/common.constant'; dotenv.config(); async function bootstrap(): Promise { @@ -24,7 +24,7 @@ async function bootstrap(): Promise { app.connectMicroservice({ transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.API_GATEWAY_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }); const expressApp = app.getHttpAdapter().getInstance(); diff --git a/apps/api-gateway/src/notification/notification.module.ts b/apps/api-gateway/src/notification/notification.module.ts index bc3bc7706..d368a572b 100644 --- a/apps/api-gateway/src/notification/notification.module.ts +++ b/apps/api-gateway/src/notification/notification.module.ts @@ -7,6 +7,7 @@ import { Module } from '@nestjs/common'; import { getNatsOptions } from '@credebl/common/nats.config'; import { NotificationController } from './notification.controller'; import { NotificationService } from './notification.service'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { NotificationService } from './notification.service'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.NOTIFICATION_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule diff --git a/apps/api-gateway/src/organization/organization.module.ts b/apps/api-gateway/src/organization/organization.module.ts index b257653fd..9846811a4 100644 --- a/apps/api-gateway/src/organization/organization.module.ts +++ b/apps/api-gateway/src/organization/organization.module.ts @@ -9,6 +9,8 @@ import { OrganizationService } from './organization.service'; import { getNatsOptions } from '@credebl/common/nats.config'; import { ImageServiceService } from '@credebl/image-service'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; + @Module({ imports: [ HttpModule, @@ -17,7 +19,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.ORGANIZATION_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule diff --git a/apps/api-gateway/src/platform/platform.module.ts b/apps/api-gateway/src/platform/platform.module.ts index 817f7db0a..f5b3119c1 100644 --- a/apps/api-gateway/src/platform/platform.module.ts +++ b/apps/api-gateway/src/platform/platform.module.ts @@ -4,6 +4,7 @@ import { PlatformService } from './platform.service'; import { ClientsModule, Transport } from '@nestjs/microservices'; import { ConfigModule } from '@nestjs/config'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -12,7 +13,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.PLATFORM_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/api-gateway/src/schema/schema.module.ts b/apps/api-gateway/src/schema/schema.module.ts index b584a1c26..268e35021 100644 --- a/apps/api-gateway/src/schema/schema.module.ts +++ b/apps/api-gateway/src/schema/schema.module.ts @@ -5,6 +5,7 @@ import { Module } from '@nestjs/common'; import { SchemaController } from './schema.controller'; import { SchemaService } from './schema.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -13,7 +14,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.SCHEMA_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) diff --git a/apps/api-gateway/src/user/user.module.ts b/apps/api-gateway/src/user/user.module.ts index 9c805028d..cae3713ae 100644 --- a/apps/api-gateway/src/user/user.module.ts +++ b/apps/api-gateway/src/user/user.module.ts @@ -7,6 +7,7 @@ import { UserController } from './user.controller'; import { UserService } from './user.service'; import { getNatsOptions } from '@credebl/common/nats.config'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.USER_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) diff --git a/apps/api-gateway/src/utilities/utilities.module.ts b/apps/api-gateway/src/utilities/utilities.module.ts index 9aa55503c..7dda4be54 100644 --- a/apps/api-gateway/src/utilities/utilities.module.ts +++ b/apps/api-gateway/src/utilities/utilities.module.ts @@ -8,6 +8,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; import { ImageServiceService } from '@credebl/image-service'; import { UtilitiesController } from './utilities.controller'; import { UtilitiesService } from './utilities.service'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -17,7 +18,7 @@ import { UtilitiesService } from './utilities.service'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.UTILITY_SERVICE, process.env.API_GATEWAY_NKEY_SEED) }, CommonModule diff --git a/apps/api-gateway/src/verification/verification.module.ts b/apps/api-gateway/src/verification/verification.module.ts index cf6097cf0..d2769ff6f 100644 --- a/apps/api-gateway/src/verification/verification.module.ts +++ b/apps/api-gateway/src/verification/verification.module.ts @@ -6,6 +6,7 @@ import { VerificationController } from './verification.controller'; import { VerificationService } from './verification.service'; import { getNatsOptions } from '@credebl/common/nats.config'; import { ImageServiceService } from '@credebl/image-service'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -14,7 +15,7 @@ import { ImageServiceService } from '@credebl/image-service'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.VERIFICATION_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/api-gateway/src/webhook/webhook.module.ts b/apps/api-gateway/src/webhook/webhook.module.ts index b0140ce6a..db38e1f7e 100644 --- a/apps/api-gateway/src/webhook/webhook.module.ts +++ b/apps/api-gateway/src/webhook/webhook.module.ts @@ -6,6 +6,7 @@ import { CommonService } from '@credebl/common'; import { HttpModule } from '@nestjs/axios'; import { getNatsOptions } from '@credebl/common/nats.config'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -14,7 +15,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.API_GATEWAY_NKEY_SEED) + options: getNatsOptions(CommonConstants.WEBHOOK_SERVICE, process.env.API_GATEWAY_NKEY_SEED) } ]) ], diff --git a/apps/connection/src/connection.module.ts b/apps/connection/src/connection.module.ts index 5182aa12d..58c71b1dd 100644 --- a/apps/connection/src/connection.module.ts +++ b/apps/connection/src/connection.module.ts @@ -9,6 +9,7 @@ import { PrismaService } from '@credebl/prisma-service'; import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; // import { nkeyAuthenticator } from 'nats'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.CONNECTION_NKEY_SEED) + options: getNatsOptions(CommonConstants.CONNECTION_SERVICE, process.env.CONNECTION_NKEY_SEED) } ]), diff --git a/apps/connection/src/main.ts b/apps/connection/src/main.ts index b92f88d1e..22c572fd3 100644 --- a/apps/connection/src/main.ts +++ b/apps/connection/src/main.ts @@ -4,6 +4,7 @@ import { HttpExceptionFilter } from 'libs/http-exception.filter'; import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(ConnectionModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.CONNECTION_NKEY_SEED) + options: getNatsOptions(CommonConstants.CONNECTION_SERVICE, process.env.CONNECTION_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/ecosystem/src/ecosystem.module.ts b/apps/ecosystem/src/ecosystem.module.ts index 1f11e9f7d..e634b4dd4 100644 --- a/apps/ecosystem/src/ecosystem.module.ts +++ b/apps/ecosystem/src/ecosystem.module.ts @@ -7,6 +7,7 @@ import { EcosystemRepository } from './ecosystem.repository'; import { PrismaService } from '@credebl/prisma-service'; import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -14,7 +15,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.ECOSYSTEM_NKEY_SEED) + options: getNatsOptions(CommonConstants.ECOSYSTEM_SERVICE, process.env.ECOSYSTEM_NKEY_SEED) } ]), diff --git a/apps/ecosystem/src/main.ts b/apps/ecosystem/src/main.ts index 47a5e9775..1ca9c8acf 100644 --- a/apps/ecosystem/src/main.ts +++ b/apps/ecosystem/src/main.ts @@ -4,6 +4,7 @@ import { HttpExceptionFilter } from 'libs/http-exception.filter'; import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(EcosystemModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.ECOSYSTEM_NKEY_SEED) + options: getNatsOptions(CommonConstants.ECOSYSTEM_SERVICE, process.env.ECOSYSTEM_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/issuance/src/issuance.module.ts b/apps/issuance/src/issuance.module.ts index 0f52a44f5..6aab0ead5 100644 --- a/apps/issuance/src/issuance.module.ts +++ b/apps/issuance/src/issuance.module.ts @@ -14,6 +14,7 @@ import { CacheModule } from '@nestjs/cache-manager'; import * as redisStore from 'cache-manager-redis-store'; import { BulkIssuanceProcessor } from './issuance.processor'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -22,7 +23,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.ISSUANCE_NKEY_SEED) + options: getNatsOptions(CommonConstants.ISSUANCE_SERVICE, process.env.ISSUANCE_NKEY_SEED) } ]), CommonModule, diff --git a/apps/issuance/src/main.ts b/apps/issuance/src/main.ts index d48f23f02..cacad1b16 100644 --- a/apps/issuance/src/main.ts +++ b/apps/issuance/src/main.ts @@ -4,6 +4,7 @@ import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { IssuanceModule } from '../src/issuance.module'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(IssuanceModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.ISSUANCE_NKEY_SEED) + options: getNatsOptions(CommonConstants.ISSUANCE_SERVICE, process.env.ISSUANCE_NKEY_SEED) }); diff --git a/apps/ledger/src/credential-definition/credential-definition.module.ts b/apps/ledger/src/credential-definition/credential-definition.module.ts index f65424046..e2c7de2f6 100644 --- a/apps/ledger/src/credential-definition/credential-definition.module.ts +++ b/apps/ledger/src/credential-definition/credential-definition.module.ts @@ -9,13 +9,15 @@ import { HttpModule } from '@nestjs/axios'; import { PrismaService } from '@credebl/prisma-service'; import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; + @Module({ imports: [ ClientsModule.register([ { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.CREDENTAILDEFINITION_NKEY_SEED) + options: getNatsOptions(CommonConstants.CREDENTIAL_DEFINITION_SERVICE, process.env.CREDENTAILDEFINITION_NKEY_SEED) } ]), HttpModule, diff --git a/apps/ledger/src/ledger.module.ts b/apps/ledger/src/ledger.module.ts index 14e7abb9f..770f578ea 100644 --- a/apps/ledger/src/ledger.module.ts +++ b/apps/ledger/src/ledger.module.ts @@ -7,6 +7,7 @@ import { CredentialDefinitionModule } from './credential-definition/credential-d import { ClientsModule, Transport } from '@nestjs/microservices'; import { LedgerRepository } from './repositories/ledger.repository'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -14,7 +15,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.LEDGER_NKEY_SEED) + options: getNatsOptions(CommonConstants.LEDGER_SERVICE, process.env.LEDGER_NKEY_SEED) } ]), diff --git a/apps/ledger/src/main.ts b/apps/ledger/src/main.ts index 00d5623f1..bf9440eaa 100644 --- a/apps/ledger/src/main.ts +++ b/apps/ledger/src/main.ts @@ -4,12 +4,12 @@ import { HttpExceptionFilter } from 'libs/http-exception.filter'; import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; - +import { CommonConstants } from '@credebl/common/common.constant'; async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(LedgerModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.LEDGER_NKEY_SEED) + options: getNatsOptions(CommonConstants.LEDGER_SERVICE, process.env.LEDGER_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/ledger/src/schema/schema.module.ts b/apps/ledger/src/schema/schema.module.ts index 49b99df38..c41952c20 100644 --- a/apps/ledger/src/schema/schema.module.ts +++ b/apps/ledger/src/schema/schema.module.ts @@ -9,13 +9,15 @@ import { HttpModule } from '@nestjs/axios'; import { PrismaService } from '@credebl/prisma-service'; import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; + @Module({ imports: [ ClientsModule.register([ { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.SCHEMA_NKEY_SEED) + options: getNatsOptions(CommonConstants.SCHEMA_SERVICE, process.env.SCHEMA_NKEY_SEED) } ]), diff --git a/apps/notification/src/main.ts b/apps/notification/src/main.ts index 0b4b87bf8..cc1d43d0b 100644 --- a/apps/notification/src/main.ts +++ b/apps/notification/src/main.ts @@ -4,6 +4,7 @@ import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { NotificationModule } from '../src/notification.module'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(NotificationModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.NOTIFICATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.NOTIFICATION_SERVICE, process.env.NOTIFICATION_NKEY_SEED) }); diff --git a/apps/notification/src/notification.module.ts b/apps/notification/src/notification.module.ts index 658d3a736..66a6f151d 100644 --- a/apps/notification/src/notification.module.ts +++ b/apps/notification/src/notification.module.ts @@ -8,6 +8,7 @@ import { NotificationController } from './notification.controller'; import { NotificationService } from './notification.service'; import { PrismaService } from '@credebl/prisma-service'; import { NotificationRepository } from './notification.repository'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -16,7 +17,7 @@ import { NotificationRepository } from './notification.repository'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.NOTIFICATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.NOTIFICATION_SERVICE, process.env.NOTIFICATION_NKEY_SEED) } ]), CommonModule, diff --git a/apps/organization/src/main.ts b/apps/organization/src/main.ts index c23f7e9f1..1ee87db06 100644 --- a/apps/organization/src/main.ts +++ b/apps/organization/src/main.ts @@ -5,6 +5,7 @@ import { OrganizationModule } from './organization.module'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; // import { nkeyAuthenticator } from 'nats'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -12,7 +13,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(OrganizationModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.ORGANIZATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.ORGANIZATION_SERVICE, process.env.ORGANIZATION_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/organization/src/organization.module.ts b/apps/organization/src/organization.module.ts index c2c86edb3..59bb111c1 100644 --- a/apps/organization/src/organization.module.ts +++ b/apps/organization/src/organization.module.ts @@ -17,6 +17,7 @@ import { CacheModule } from '@nestjs/cache-manager'; import { getNatsOptions } from '@credebl/common/nats.config'; import { ClientRegistrationService } from '@credebl/client-registration'; import { KeycloakUrlService } from '@credebl/keycloak-url'; +import { CommonConstants } from '@credebl/common/common.constant'; import { AwsService } from '@credebl/aws'; @Module({ @@ -25,7 +26,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.ORGANIZATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.ORGANIZATION_SERVICE, process.env.ORGANIZATION_NKEY_SEED) } ]), CommonModule, diff --git a/apps/user/src/main.ts b/apps/user/src/main.ts index 4acd6ddeb..8c3df1edc 100644 --- a/apps/user/src/main.ts +++ b/apps/user/src/main.ts @@ -4,13 +4,14 @@ import { NestFactory } from '@nestjs/core'; import { UserModule } from './user.module'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(UserModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.USER_NKEY_SEED) + options: getNatsOptions(CommonConstants.USER_SERVICE, process.env.USER_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/user/src/user.module.ts b/apps/user/src/user.module.ts index 3a1097d69..7ecead247 100644 --- a/apps/user/src/user.module.ts +++ b/apps/user/src/user.module.ts @@ -19,6 +19,7 @@ import { UserService } from './user.service'; import { UserDevicesRepository } from '../repositories/user-device.repository'; import { getNatsOptions } from '@credebl/common/nats.config'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -26,7 +27,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.USER_NKEY_SEED) + options: getNatsOptions(CommonConstants.USER_SERVICE, process.env.USER_NKEY_SEED) } ]), diff --git a/apps/utility/src/main.ts b/apps/utility/src/main.ts index 4de5fd578..ee165502d 100644 --- a/apps/utility/src/main.ts +++ b/apps/utility/src/main.ts @@ -4,6 +4,7 @@ import { NestFactory } from '@nestjs/core'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { getNatsOptions } from '@credebl/common/nats.config'; import { UtilitiesModule } from './utilities.module'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(UtilitiesModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.UTILITIES_NKEY_SEED) + options: getNatsOptions(CommonConstants.UTILITY_SERVICE, process.env.UTILITIES_NKEY_SEED) }); app.useGlobalFilters(new HttpExceptionFilter()); diff --git a/apps/utility/src/utilities.module.ts b/apps/utility/src/utilities.module.ts index 5048add05..51c31d6dd 100644 --- a/apps/utility/src/utilities.module.ts +++ b/apps/utility/src/utilities.module.ts @@ -8,6 +8,7 @@ import { UtilitiesController } from './utilities.controller'; import { UtilitiesService } from './utilities.service'; import { UtilitiesRepository } from './utilities.repository'; import { AwsService } from '@credebl/aws'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -15,7 +16,7 @@ import { AwsService } from '@credebl/aws'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.UTILITIES_NKEY_SEED) + options: getNatsOptions(CommonConstants.UTILITY_SERVICE, process.env.UTILITIES_NKEY_SEED) } ]), CommonModule, diff --git a/apps/verification/src/main.ts b/apps/verification/src/main.ts index 7c0bcf689..b8ff0ea23 100644 --- a/apps/verification/src/main.ts +++ b/apps/verification/src/main.ts @@ -4,6 +4,7 @@ import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { VerificationModule } from './verification.module'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(VerificationModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.VERIFICATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.VERIFICATION_SERVICE, process.env.VERIFICATION_NKEY_SEED) }); diff --git a/apps/verification/src/verification.module.ts b/apps/verification/src/verification.module.ts index 6c490c541..1ef28460d 100644 --- a/apps/verification/src/verification.module.ts +++ b/apps/verification/src/verification.module.ts @@ -9,13 +9,15 @@ import { getNatsOptions } from '@credebl/common/nats.config'; import { OutOfBandVerification } from '../templates/out-of-band-verification.template'; import { EmailDto } from '@credebl/common/dtos/email.dto'; import { CacheModule } from '@nestjs/cache-manager'; +import { CommonConstants } from '@credebl/common/common.constant'; + @Module({ imports: [ ClientsModule.register([ { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.VERIFICATION_NKEY_SEED) + options: getNatsOptions(CommonConstants.VERIFICATION_SERVICE, process.env.VERIFICATION_NKEY_SEED) } ]), diff --git a/apps/webhook/src/main.ts b/apps/webhook/src/main.ts index d5a7010a9..2048425a5 100644 --- a/apps/webhook/src/main.ts +++ b/apps/webhook/src/main.ts @@ -4,6 +4,7 @@ import { Logger } from '@nestjs/common'; import { MicroserviceOptions, Transport } from '@nestjs/microservices'; import { WebhookModule } from '../src/webhook.module'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; const logger = new Logger(); @@ -11,7 +12,7 @@ async function bootstrap(): Promise { const app = await NestFactory.createMicroservice(WebhookModule, { transport: Transport.NATS, - options: getNatsOptions(process.env.ISSUANCE_NKEY_SEED) + options: getNatsOptions(CommonConstants.WEBHOOK_SERVICE, process.env.ISSUANCE_NKEY_SEED) }); diff --git a/apps/webhook/src/webhook.module.ts b/apps/webhook/src/webhook.module.ts index b8bf50c54..229a7dd68 100644 --- a/apps/webhook/src/webhook.module.ts +++ b/apps/webhook/src/webhook.module.ts @@ -7,6 +7,7 @@ import { WebhookController } from './webhook.controller'; import { WebhookRepository } from './webhook.repository'; import { WebhookService } from './webhook.service'; import { getNatsOptions } from '@credebl/common/nats.config'; +import { CommonConstants } from '@credebl/common/common.constant'; @Module({ imports: [ @@ -15,7 +16,7 @@ import { getNatsOptions } from '@credebl/common/nats.config'; { name: 'NATS_CLIENT', transport: Transport.NATS, - options: getNatsOptions(process.env.ISSUANCE_NKEY_SEED) + options: getNatsOptions(CommonConstants.WEBHOOK_SERVICE, process.env.ISSUANCE_NKEY_SEED) } ]), CommonModule diff --git a/libs/common/src/common.constant.ts b/libs/common/src/common.constant.ts index ebb8f4171..ffc860fe1 100644 --- a/libs/common/src/common.constant.ts +++ b/libs/common/src/common.constant.ts @@ -117,7 +117,7 @@ export enum CommonConstants { URL_SHAGENT_SEND_QUESTION = '/multi-tenancy/question-answer/question/#/@', URL_SHAGENT_SEND_ANSWER = '/multi-tenancy/question-answer/answer/#/@', URL_SHAGENT_QUESTION_ANSWER_RECORD = '/multi-tenancy/question-answer/#', - + // PROOF SERVICES URL_SEND_PROOF_REQUEST = '/proofs/request-proof', URL_GET_PROOF_PRESENTATIONS = '/proofs', @@ -134,7 +134,6 @@ export enum CommonConstants { // CREATE KEYS CREATE_POLYGON_SECP256k1_KEY = '/polygon/create-keys', - // ENTITY NAMES ENTITY_NAME_TEMPLATE = 'templates', @@ -243,7 +242,7 @@ export enum CommonConstants { // agent status URL_AGENT_STATUS = '/agent', - + // Tenant Status PENDING_STATE = 0, REJECT_STATE = 2, @@ -270,11 +269,10 @@ export enum CommonConstants { ACTIVE_NON_ADMIN_USER = 1, ALL_NON_ADMIN_USER = 3, - // Platform admin Details - PLATFORM_ADMIN_EMAIL='platform.admin@yopmail.com', - PLATFORM_ADMIN_ORG='Platform-admin', - PLATFORM_ADMIN_ORG_ROLE='platform_admin', + PLATFORM_ADMIN_EMAIL = 'platform.admin@yopmail.com', + PLATFORM_ADMIN_ORG = 'Platform-admin', + PLATFORM_ADMIN_ORG_ROLE = 'platform_admin', //onBoarding Type ONBOARDING_TYPE_ADMIN = 0, @@ -316,12 +314,33 @@ export enum CommonConstants { KEYTYPE = 'ed25519', METHOD = 'indy', NETWORK = 'bcovrin:testnet', - ROLE = 'endorser', - - //CacheInfo -CACHE_SHARED_APIKEY_KEY = "dedicatedApiKey", -CACHE_APIKEY_KEY = "sharedApiKey", -CACHE_TTL_SECONDS = 604800 + ROLE = 'endorser', + + //CacheInfo + CACHE_SHARED_APIKEY_KEY = 'dedicatedApiKey', + CACHE_APIKEY_KEY = 'sharedApiKey', + CACHE_TTL_SECONDS = 604800, + + // MICROSERVICES NAMES + API_GATEWAY_SERVICE = 'api-gateway', + ORGANIZATION_SERVICE = 'organization', + USER_SERVICE = 'user', + AUTH_SERVICE = 'authz', + FIDO_SERVICE = 'fido', + UTILITY_SERVICE = 'utilitites', + CONNECTION_SERVICE = 'connection', + LEDGER_SERVICE = 'ledger', + PLATFORM_SERVICE = 'platform', + SCHEMA_SERVICE = 'schema', + CREDENTIAL_DEFINITION_SERVICE = 'credential-definition', + AGENT_SERVICE = 'agent-service', + AGENT_PROVISIONING = 'agent-provisioning', + ISSUANCE_SERVICE = 'issuance', + VERIFICATION_SERVICE = 'verification', + ECOSYSTEM_SERVICE = 'ecosystem', + WEBHOOK_SERVICE = 'webhook', + NOTIFICATION_SERVICE = 'notification', + GEO_LOCATION_SERVICE = 'geo-location' } export const postgresqlErrorCodes = []; diff --git a/libs/common/src/nats.config.ts b/libs/common/src/nats.config.ts index 3af2b867f..331256866 100644 --- a/libs/common/src/nats.config.ts +++ b/libs/common/src/nats.config.ts @@ -1,13 +1,28 @@ +import { NATSReconnects } from '@credebl/enum/enum'; import { Authenticator, nkeyAuthenticator } from 'nats'; export const getNatsOptions = ( - nkeySeed?: string + serviceName: string, nkeySeed?: string ): { servers: string[]; authenticator?: Authenticator; -} => nkeySeed -? { - servers: [`${process.env.NATS_URL}`], - authenticator: nkeyAuthenticator(new TextEncoder().encode(nkeySeed)) - } - : { servers: [`${process.env.NATS_URL}`] }; + maxReconnectAttempts: NATSReconnects; + reconnectTimeWait: NATSReconnects; + queue?: string; +} => { + const baseOptions = { + servers: `${process.env.NATS_URL}`.split(','), + maxReconnectAttempts: NATSReconnects.maxReconnectAttempts, + reconnectTimeWait: NATSReconnects.reconnectTimeWait, + queue: serviceName + }; + + if (nkeySeed) { + return { + ...baseOptions, + authenticator: nkeyAuthenticator(new TextEncoder().encode(nkeySeed)) + }; + } + return baseOptions; +}; + diff --git a/libs/enum/src/enum.ts b/libs/enum/src/enum.ts index d5af443fd..31e4ab0ae 100644 --- a/libs/enum/src/enum.ts +++ b/libs/enum/src/enum.ts @@ -1,3 +1,8 @@ +export enum NATSReconnects { + maxReconnectAttempts = (10 * 60) / 5, // 10 minutes with a reconnection attempt every 5 seconds + reconnectTimeWait = 5000 // 5 second delay between reconnection attempts +} + export enum SortValue { ASC = 'asc', DESC = 'desc' From 1f02bd54105851e05a02127bd0ba477c5ead6cab Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Fri, 28 Jun 2024 13:46:09 +0530 Subject: [PATCH 2/3] wip: nats-cluster configurations Signed-off-by: bhavanakarwade --- libs/common/src/nats.config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/common/src/nats.config.ts b/libs/common/src/nats.config.ts index 331256866..deeeca557 100644 --- a/libs/common/src/nats.config.ts +++ b/libs/common/src/nats.config.ts @@ -1,8 +1,9 @@ import { NATSReconnects } from '@credebl/enum/enum'; import { Authenticator, nkeyAuthenticator } from 'nats'; +import { CommonConstants } from './common.constant'; export const getNatsOptions = ( - serviceName: string, nkeySeed?: string + serviceName?: string, nkeySeed?: string ): { servers: string[]; authenticator?: Authenticator; @@ -14,7 +15,7 @@ export const getNatsOptions = ( servers: `${process.env.NATS_URL}`.split(','), maxReconnectAttempts: NATSReconnects.maxReconnectAttempts, reconnectTimeWait: NATSReconnects.reconnectTimeWait, - queue: serviceName + queue: `${CommonConstants.API_GATEWAY_SERVICE}` }; if (nkeySeed) { From 573c3b64c5370e68a897dba77fc5592880b82dff Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 28 Jun 2024 13:53:26 +0530 Subject: [PATCH 3/3] Change in QA pipeline tag --- .github/workflows/qa-agent.yml | 2 +- .github/workflows/qa-api-gateway.yml | 2 +- .github/workflows/qa-connection.yml | 2 +- .github/workflows/qa-ecosystem.yml | 2 +- .github/workflows/qa-issuance.yml | 2 +- .github/workflows/qa-ledger.yml | 2 +- .github/workflows/qa-notification.yml | 2 +- .github/workflows/qa-organization.yml | 2 +- .github/workflows/qa-user.yml | 2 +- .github/workflows/qa-utility.yml | 2 +- .github/workflows/qa-verification.yml | 2 +- .github/workflows/qa-webhook.yml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/qa-agent.yml b/.github/workflows/qa-agent.yml index 492176985..cadba43ec 100644 --- a/.github/workflows/qa-agent.yml +++ b/.github/workflows/qa-agent.yml @@ -4,7 +4,7 @@ name: Build and deploy AGENT app to QA ECS on: push: tags: - - 'qa-agent-service*' + - 'qa*' env: ECR_IMAGE_TAG: "AGENT_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-api-gateway.yml b/.github/workflows/qa-api-gateway.yml index 7e26f5158..b01b2f48b 100644 --- a/.github/workflows/qa-api-gateway.yml +++ b/.github/workflows/qa-api-gateway.yml @@ -3,7 +3,7 @@ name: Build and deploy API-GATEWAY app to QA ECS on: push: tags: - - 'qa-api-gateway*' + - 'qa*' env: ECR_IMAGE_TAG: "API-GATEWAY_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-connection.yml b/.github/workflows/qa-connection.yml index 5e0bd432a..091142dae 100644 --- a/.github/workflows/qa-connection.yml +++ b/.github/workflows/qa-connection.yml @@ -3,7 +3,7 @@ name: Build and deploy CONNECTION app to QA ECS on: push: tags: - - 'qa-connection*' + - 'qa*' env: ECR_IMAGE_TAG: "CONNECTION_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-ecosystem.yml b/.github/workflows/qa-ecosystem.yml index f9921168e..0ed5270aa 100644 --- a/.github/workflows/qa-ecosystem.yml +++ b/.github/workflows/qa-ecosystem.yml @@ -3,7 +3,7 @@ name: Build and deploy ECOSYSTEM app to QA ECS on: push: tags: - - 'qa-ecosystem*' + - 'qa' env: ECR_IMAGE_TAG: "ECOSYSTEM_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-issuance.yml b/.github/workflows/qa-issuance.yml index 9581d9f96..3a29ad037 100644 --- a/.github/workflows/qa-issuance.yml +++ b/.github/workflows/qa-issuance.yml @@ -4,7 +4,7 @@ name: Build and deploy ISSUANCE app to QA ECS on: push: tags: - - 'qa-issuance*' + - 'qa*' env: ECR_IMAGE_TAG: "ISSUANCE_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-ledger.yml b/.github/workflows/qa-ledger.yml index e09cc88b2..6fc4ae384 100644 --- a/.github/workflows/qa-ledger.yml +++ b/.github/workflows/qa-ledger.yml @@ -3,7 +3,7 @@ name: Build and deploy LEDGER app to QA ECS on: push: tags: - - 'qa-ledger*' + - 'qa*' env: ECR_IMAGE_TAG: "LEDGER_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-notification.yml b/.github/workflows/qa-notification.yml index d9a75a491..304d6bcf5 100644 --- a/.github/workflows/qa-notification.yml +++ b/.github/workflows/qa-notification.yml @@ -3,7 +3,7 @@ name: Build and deploy NOTIFICATION app to QA ECS on: push: tags: - - 'qa-notification*' + - 'qa*' env: ECR_IMAGE_TAG: "NOTIFICATION_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-organization.yml b/.github/workflows/qa-organization.yml index 86b6e6798..ec952e959 100644 --- a/.github/workflows/qa-organization.yml +++ b/.github/workflows/qa-organization.yml @@ -3,7 +3,7 @@ name: Build and deploy ORGANIZATION app to QA ECS on: push: tags: - - 'qa-organization*' + - 'qa*' env: ECR_IMAGE_TAG: "ORGANIZATION_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-user.yml b/.github/workflows/qa-user.yml index 3e25239a4..46f7cda47 100644 --- a/.github/workflows/qa-user.yml +++ b/.github/workflows/qa-user.yml @@ -3,7 +3,7 @@ name: Build and deploy USER app to QA ECS on: push: tags: - - 'qa-user*' + - 'qa*' env: ECR_IMAGE_TAG: "USER_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-utility.yml b/.github/workflows/qa-utility.yml index 07ce6d6a6..80ae09bbc 100644 --- a/.github/workflows/qa-utility.yml +++ b/.github/workflows/qa-utility.yml @@ -3,7 +3,7 @@ name: Build and deploy UTILITY app to QA ECS on: push: tags: - - 'qa-utility*' + - 'qa*' env: ECR_IMAGE_TAG: "UTILITY_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-verification.yml b/.github/workflows/qa-verification.yml index 415f1a8d6..c135918be 100644 --- a/.github/workflows/qa-verification.yml +++ b/.github/workflows/qa-verification.yml @@ -3,7 +3,7 @@ name: Build and deploy VERIFICATION app to QA ECS on: push: tags: - - 'qa-verification*' + - 'qa*' env: ECR_IMAGE_TAG: "VERIFICATION_V_${{ github.run_number }}" diff --git a/.github/workflows/qa-webhook.yml b/.github/workflows/qa-webhook.yml index bb984ec92..4e9bacf7f 100644 --- a/.github/workflows/qa-webhook.yml +++ b/.github/workflows/qa-webhook.yml @@ -3,7 +3,7 @@ name: Build and deploy WEBHOOK app to QA ECS on: push: tags: - - 'qa-webhook*' + - 'qa*' env: ECR_IMAGE_TAG: "WEBHOOK_V_${{ github.run_number }}"