Skip to content

Commit cf5371a

Browse files
authored
feat: elk code on dco fixed branch (#1067)
* feat: elk code on dco fixed branch Signed-off-by: Tipu_Singh <[email protected]> * added nats client in verification module Signed-off-by: Tipu_Singh <[email protected]> * added nats client as read only Signed-off-by: Tipu_Singh <[email protected]> * sonar lint issues Signed-off-by: Tipu_Singh <[email protected]> * sonarlint and comments Signed-off-by: Tipu_Singh <[email protected]> * fix: build issue Signed-off-by: Tipu_Singh <[email protected]> * changed import path Signed-off-by: Tipu_Singh <[email protected]> --------- Signed-off-by: Tipu_Singh <[email protected]>
1 parent 203ba58 commit cf5371a

File tree

107 files changed

+2464
-403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2464
-403
lines changed

.env.demo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,10 @@ OOB_BATCH_SIZE=10
129129
MAX_ORG_LIMIT=10
130130
FIDO_API_ENDPOINT=http://localhost:8000
131131

132-
IS_ECOSYSTEM_ENABLE=false
132+
IS_ECOSYSTEM_ENABLE=false
133+
CONSOLE_LOG_FLAG=true // Enable or disable console ELK logs
134+
ELK_LOG=true // ELK flag
135+
LOG_LEVEL=debug // ELK log level
136+
ELK_LOG_PATH = "http://localhost:9200/" // ELK log path
137+
ELK_USERNAME=elastic // ELK user username
138+
ELK_PASSWORD=xxxxxx // ELK user password

.env.sample

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,10 @@ FILEUPLOAD_CACHE_TTL= //Provide file upload cache ttl
155155

156156
FIELD_UPLOAD_SIZE= //Provide field upload size
157157

158-
IS_ECOSYSTEM_ENABLE= //Set this flag to `true` to enable the ecosystem, or `false` to disable it.
158+
IS_ECOSYSTEM_ENABLE= //Set this flag to `true` to enable the ecosystem, or `false` to disable it.
159+
CONSOLE_LOG_FLAG=true // Enable or disable console ELK logs
160+
ELK_LOG=true // ELK flag
161+
LOG_LEVEL=debug // ELK log level
162+
ELK_LOG_PATH = "http://localhost:9200/" // ELK log path
163+
ELK_USERNAME=elastic // ELK user username
164+
ELK_PASSWORD=xxxxxx // ELK user password

apps/agent-provisioning/src/agent-provisioning.module.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,34 @@ import { AgentProvisioningService } from './agent-provisioning.service';
44
import { ClientsModule, Transport } from '@nestjs/microservices';
55
import { ConfigModule } from '@nestjs/config';
66
import { getNatsOptions } from '@credebl/common/nats.config';
7-
import { CommonConstants } from '@credebl/common/common.constant';
7+
import { CommonConstants, MICRO_SERVICE_NAME } from '@credebl/common/common.constant';
8+
import { GlobalConfigModule } from '@credebl/config/global-config.module';
9+
import { LoggerModule } from '@credebl/logger/logger.module';
10+
import { ContextInterceptorModule } from '@credebl/context/contextInterceptorModule';
11+
import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
812
@Module({
913
imports: [
1014
ConfigModule.forRoot(),
15+
GlobalConfigModule,
16+
LoggerModule,
17+
PlatformConfig,
18+
ContextInterceptorModule,
1119
ClientsModule.register([
1220
{
1321
name: 'NATS_CLIENT',
1422
transport: Transport.NATS,
1523
options: getNatsOptions(CommonConstants.AGENT_PROVISIONING, process.env.AGENT_PROVISIONING_NKEY_SEED)
16-
1724
}
1825
])
1926
],
2027
controllers: [AgentProvisioningController],
21-
providers: [AgentProvisioningService, Logger]
28+
providers: [
29+
AgentProvisioningService,
30+
Logger,
31+
{
32+
provide: MICRO_SERVICE_NAME,
33+
useValue: 'Agent-provisioning'
34+
}
35+
]
2236
})
23-
export class AgentProvisioningModule { }
37+
export class AgentProvisioningModule {}

apps/agent-provisioning/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { MicroserviceOptions, Transport } from '@nestjs/microservices';
55
import { AgentProvisioningModule } from './agent-provisioning.module';
66
import { getNatsOptions } from '@credebl/common/nats.config';
77
import { CommonConstants } from '@credebl/common/common.constant';
8+
import NestjsLoggerServiceAdapter from '@credebl/logger/nestjsLoggerServiceAdapter';
89
const logger = new Logger();
910

1011
async function bootstrap(): Promise<void> {
@@ -13,6 +14,7 @@ async function bootstrap(): Promise<void> {
1314
transport: Transport.NATS,
1415
options: getNatsOptions(CommonConstants.AGENT_PROVISIONING, process.env.AGENT_PROVISIONING_NKEY_SEED)
1516
});
17+
app.useLogger(app.get(NestjsLoggerServiceAdapter));
1618
app.useGlobalFilters(new HttpExceptionFilter());
1719

1820
await app.listen();

apps/agent-service/src/agent-service.module.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ import { ConnectionRepository } from 'apps/connection/src/connection.repository'
1111
import { CacheModule } from '@nestjs/cache-manager';
1212
import { getNatsOptions } from '@credebl/common/nats.config';
1313
import { UserActivityRepository } from 'libs/user-activity/repositories';
14-
import { CommonConstants } from '@credebl/common/common.constant';
14+
import { CommonConstants, MICRO_SERVICE_NAME } from '@credebl/common/common.constant';
15+
import { LoggerModule } from '@credebl/logger/logger.module';
16+
import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
17+
import { GlobalConfigModule } from '@credebl/config/global-config.module';
18+
import { ContextInterceptorModule } from '@credebl/context/contextInterceptorModule';
19+
import { NATSClient } from '@credebl/common/NATSClient';
20+
1521

1622
@Module({
1723
imports: [
1824
ConfigModule.forRoot(),
25+
GlobalConfigModule,
26+
LoggerModule, PlatformConfig, ContextInterceptorModule,
1927
ClientsModule.register([
2028
{
2129
name: 'NATS_CLIENT',
@@ -34,7 +42,12 @@ import { CommonConstants } from '@credebl/common/common.constant';
3442
Logger,
3543
ConnectionService,
3644
ConnectionRepository,
37-
UserActivityRepository
45+
UserActivityRepository,
46+
{
47+
provide: MICRO_SERVICE_NAME,
48+
useValue: 'Agent-service'
49+
},
50+
NATSClient
3851
],
3952
exports: [AgentServiceService, AgentServiceRepository, AgentServiceModule]
4053
})

apps/agent-service/src/agent-service.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ import { InvitationMessage } from '@credebl/common/interfaces/agent-service.inte
7676
import * as CryptoJS from 'crypto-js';
7777
import { UserActivityRepository } from 'libs/user-activity/repositories';
7878
import { PrismaService } from '@credebl/prisma-service';
79+
import { from } from 'rxjs';
80+
import { NATSClient } from '@credebl/common/NATSClient';
7981

8082
@Injectable()
8183
@WebSocketGateway()
@@ -89,7 +91,8 @@ export class AgentServiceService {
8991
private readonly connectionService: ConnectionService,
9092
@Inject('NATS_CLIENT') private readonly agentServiceProxy: ClientProxy,
9193
@Inject(CACHE_MANAGER) private cacheService: Cache,
92-
private readonly userActivityRepository: UserActivityRepository
94+
private readonly userActivityRepository: UserActivityRepository,
95+
private readonly natsClient : NATSClient
9396
) {}
9497

9598
async ReplaceAt(input, search, replace, start, end): Promise<string> {
@@ -1925,8 +1928,8 @@ async _updateIsSchemaArchivedFlag(did: string): Promise<{
19251928
response: string;
19261929
}> {
19271930
try {
1928-
return this.agentServiceProxy
1929-
.send<string>(pattern, payload)
1931+
return from(this.natsClient
1932+
.send<string>(this.agentServiceProxy, pattern, payload))
19301933
.pipe(map((response) => ({ response })))
19311934
.toPromise()
19321935
.catch((error) => {

apps/agent-service/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { MicroserviceOptions, Transport } from '@nestjs/microservices';
88
import { getNatsOptions } from '@credebl/common/nats.config';
99
import { CommonConstants } from '@credebl/common/common.constant';
1010
import { Ledgers } from '@credebl/enum/enum';
11+
import NestjsLoggerServiceAdapter from '@credebl/logger/nestjsLoggerServiceAdapter';
1112

1213
const logger = new Logger();
1314

@@ -18,6 +19,7 @@ async function bootstrap(): Promise<void> {
1819
options: getNatsOptions(CommonConstants.AGENT_SERVICE, process.env.AGENT_SERVICE_NKEY_SEED)
1920

2021
});
22+
app.useLogger(app.get(NestjsLoggerServiceAdapter));
2123
app.useGlobalFilters(new HttpExceptionFilter());
2224

2325
await app.listen();

apps/api-gateway/src/agent-service/agent-service.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AgentController } from './agent-service.controller';
88
import { AgentService } from './agent-service.service';
99
import { getNatsOptions } from '@credebl/common/nats.config';
1010
import { CommonConstants } from '@credebl/common/common.constant';
11+
import { NATSClient } from '@credebl/common/NATSClient';
1112

1213
@Module({
1314
imports: [
@@ -24,6 +25,6 @@ import { CommonConstants } from '@credebl/common/common.constant';
2425
])
2526
],
2627
controllers: [AgentController],
27-
providers: [AgentService, CommonService]
28+
providers: [AgentService, CommonService, NATSClient]
2829
})
2930
export class AgentModule { }

apps/api-gateway/src/agent-service/agent-service.service.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { AgentStatus } from './interface/agent-service.interface';
99
import { CreateDidDto } from './dto/create-did.dto';
1010
import { CreateWalletDto } from './dto/create-wallet.dto';
1111
import { AgentConfigureDto } from './dto/agent-configure.dto';
12+
import { NATSClient } from '@credebl/common/NATSClient';
1213

1314
@Injectable()
1415
export class AgentService extends BaseService {
1516
constructor(
16-
@Inject('NATS_CLIENT') private readonly agentServiceProxy: ClientProxy
17+
@Inject('NATS_CLIENT') private readonly agentServiceProxy: ClientProxy,
18+
private readonly natsClient : NATSClient
1719
) {
1820
super('AgentService');
1921
}
@@ -28,63 +30,63 @@ export class AgentService extends BaseService {
2830
const payload = { agentSpinupDto, user };
2931

3032
// NATS call
31-
return this.sendNatsMessage(this.agentServiceProxy, 'agent-spinup', payload);
33+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'agent-spinup', payload);
3234
}
3335

3436
async createTenant(createTenantDto: CreateTenantDto, user: user): Promise<AgentSpinUpSatus> {
3537
const payload = { createTenantDto, user };
3638

3739
// NATS call
38-
return this.sendNatsMessage(this.agentServiceProxy, 'create-tenant', payload);
40+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'create-tenant', payload);
3941
}
4042

4143
async createDid(createDidDto: CreateDidDto, orgId:string, user: user): Promise<object> {
4244
const payload = { createDidDto, orgId, user };
4345

4446
// NATS call
45-
return this.sendNatsMessage(this.agentServiceProxy, 'create-did', payload);
47+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'create-did', payload);
4648
}
4749

4850
async createWallet(createWalletDto: CreateWalletDto, user: user): Promise<IWalletRecord> {
4951
const payload = { createWalletDto, user };
5052
// NATS call
51-
return this.sendNatsMessage(this.agentServiceProxy, 'create-wallet', payload);
53+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'create-wallet', payload);
5254
}
5355

5456
async getAgentHealth(user: user, orgId:string): Promise<AgentStatus> {
5557
const payload = { user, orgId };
5658

5759
// NATS call
58-
return this.sendNatsMessage(this.agentServiceProxy, 'agent-health', payload);
60+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'agent-health', payload);
5961

6062
}
6163

6264
async getLedgerConfig(user: user): Promise<object> {
6365
const payload = { user };
6466

6567
// NATS call
66-
return this.sendNatsMessage(this.agentServiceProxy, 'get-ledger-config', payload);
68+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'get-ledger-config', payload);
6769
}
6870

6971
async createSecp256k1KeyPair(orgId:string): Promise<object> {
7072
const payload = {orgId};
7173
// NATS call
7274

73-
return this.sendNatsMessage(this.agentServiceProxy, 'polygon-create-keys', payload);
75+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'polygon-create-keys', payload);
7476
}
7577

7678
async agentConfigure(agentConfigureDto: AgentConfigureDto, user: user): Promise<object> {
7779
const payload = { agentConfigureDto, user };
7880
// NATS call
7981

80-
return this.sendNatsMessage(this.agentServiceProxy, 'agent-configure', payload);
82+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'agent-configure', payload);
8183
}
8284

8385
async deleteWallet(orgId: string, user: user): Promise<object> {
8486
const payload = { orgId, user };
8587
// NATS call
8688

87-
return this.sendNatsMessage(this.agentServiceProxy, 'delete-wallet', payload);
89+
return this.natsClient.sendNatsMessage(this.agentServiceProxy, 'delete-wallet', payload);
8890
}
8991

9092
}

apps/api-gateway/src/agent/agent.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CommonModule } from '../../../../libs/common/src/common.module';
77
import { CommonService } from '../../../../libs/common/src/common.service';
88
import { ConfigModule } from '@nestjs/config';
99
import { commonNatsOptions } from 'libs/service/nats.options';
10+
import { NATSClient } from '@credebl/common/NATSClient';
1011

1112
@Module({
1213
imports: [
@@ -21,6 +22,6 @@ import { commonNatsOptions } from 'libs/service/nats.options';
2122
])
2223
],
2324
controllers: [AgentController],
24-
providers: [AgentService, CommonService]
25+
providers: [AgentService, CommonService, NATSClient]
2526
})
2627
export class AgentModule { }

0 commit comments

Comments
 (0)