Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updated verbose from services #424

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api-gateway/src/connection/connection.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IResponse } from '@credebl/common/interfaces/response.interface';
import { ResponseMessages } from '@credebl/common/response-messages';
import { Controller, Logger, Post, Body, UseGuards, HttpStatus, Res, Get, Param, UseFilters, Query, Inject } from '@nestjs/common';
import { Controller, Post, Logger, Body, UseGuards, HttpStatus, Res, Get, Param, UseFilters, Query, Inject } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiBearerAuth, ApiExcludeEndpoint, ApiForbiddenResponse, ApiOperation, ApiQuery, ApiResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { User } from '../authz/decorators/user.decorator';
Expand Down
4 changes: 2 additions & 2 deletions apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Controller,
Post,
Body,
Logger,
UseGuards,
BadRequestException,
HttpStatus,
Expand All @@ -16,7 +15,8 @@ import {
UseFilters,
Header,
UploadedFile,
UseInterceptors
UseInterceptors,
Logger
} from '@nestjs/common';
import {
ApiTags,
Expand Down
3 changes: 2 additions & 1 deletion apps/api-gateway/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { getNatsOptions } from '@credebl/common/nats.config';

import helmet from 'helmet';
import { NodeEnvironment } from '@credebl/enum/enum';
dotenv.config();

async function bootstrap(): Promise<void> {

const app = await NestFactory.create(AppModule, {
// httpsOptions,
logger: NodeEnvironment.PRODUCTION !== process.env.PLATFORM_PROFILE_MODE ? ['log', 'debug', 'error', 'verbose', 'warn'] : ['error', 'warn']
});

app.connectMicroservice<MicroserviceOptions>({
Expand Down
2 changes: 0 additions & 2 deletions apps/connection/src/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class ConnectionService {
const url = await this.getAgentUrl(orgAgentType, agentEndPoint, agentDetails?.tenantId);

let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----getConnections,${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down Expand Up @@ -294,7 +293,6 @@ export class ConnectionService {

// const apiKey = await this._getOrgAgentApiKey(orgId);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----getConnectionsById,${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down
3 changes: 0 additions & 3 deletions apps/ecosystem/src/ecosystem.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ async findEcosystemMembers(
}
});
const schemaArray = [];
this.logger.error(`In error schemaDetails2: ${JSON.stringify(schemaDetails)}`);
schemaDetails.map((schemaData) => schemaArray.push(schemaData.resourceId));
const schemasResult = await this.prisma.schema.findMany({
where: {
Expand All @@ -695,8 +694,6 @@ async findEcosystemMembers(
}
});
const schemasCount = schemaArray.length;

this.logger.error(`In error schemaDetails3: ${JSON.stringify(schemasResult)}`);
return { schemasCount, schemasResult };

} catch (error) {
Expand Down
7 changes: 0 additions & 7 deletions apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,6 @@ export class EcosystemService {
ecosystemLeadAgentDetails?.tenantId
);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(ecosystemLeadDetails.orgId);
}
Expand Down Expand Up @@ -1183,16 +1182,12 @@ export class EcosystemService {
ecosystemMemberDetails,
ecosystemLeadAgentDetails
);
// const apiKey = await this._getOrgAgentApiKey(orgId);

this.logger.log(`orgId ::: ${orgId}`);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}


const submitTransactionRequest = await this._submitTransaction(payload, url, apiKey);

if ('failed' === submitTransactionRequest['message'].state) {
Expand Down Expand Up @@ -1423,7 +1418,6 @@ export class EcosystemService {
async getAllEcosystemSchemas(ecosystemSchemas: GetAllSchemaList): Promise<object> {
try {
const response = await this.ecosystemRepository.getAllEcosystemSchemasDetails(ecosystemSchemas);
this.logger.error(`In error getAllEcosystemSchemas1: ${JSON.stringify(response)}`);
const schemasDetails = response?.schemasResult.map((schemaAttributeItem) => {
const attributes = JSON.parse(schemaAttributeItem.attributes);
return { ...schemaAttributeItem, attributes };
Expand All @@ -1438,7 +1432,6 @@ export class EcosystemService {
lastPage: Math.ceil(response.schemasCount / ecosystemSchemas.pageSize),
data: schemasDetails
};
this.logger.error(`In error getAllEcosystemSchemas1: ${JSON.stringify(response)}`);
return schemasResponse;
} catch (error) {
this.logger.error(`In error fetching all ecosystem schemas: ${JSON.stringify(error)}`);
Expand Down
4 changes: 1 addition & 3 deletions apps/issuance/src/issuance.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Controller, Logger } from '@nestjs/common';
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
import { ClientDetails, IIssuance, IIssueCredentials, IIssueCredentialsDefinitions, ImportFileDetails, IssueCredentialWebhookPayload, OutOfBandCredentialOffer, PreviewRequest } from '../interfaces/issuance.interfaces';
import { IssuanceService } from './issuance.service';
import { IIssuedCredential } from '@credebl/common/interfaces/issuance.interface';

@Controller()
export class IssuanceController {
private readonly logger = new Logger('issuanceService');
constructor(private readonly issuanceService: IssuanceService) { }

@MessagePattern({ cmd: 'send-credential-create-offer' })
Expand Down Expand Up @@ -56,7 +55,6 @@ export class IssuanceController {
async importCSV(payload: {
importFileDetails: ImportFileDetails
}): Promise<string> {
this.logger.log(`payload.importFileDetails----${payload.importFileDetails}`);
return this.issuanceService.importAndPreviewDataForIssuance(payload.importFileDetails);
}

Expand Down
22 changes: 1 addition & 21 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class IssuanceService {

let apiKey;
apiKey = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey---${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down Expand Up @@ -257,7 +256,6 @@ export class IssuanceService {
// const apiKey = platformConfig?.sgApiKey;
// const apiKey = await this._getOrgAgentApiKey(orgId);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down Expand Up @@ -331,7 +329,6 @@ export class IssuanceService {
// const { apiKey } = agentDetails;
// const apiKey = await this._getOrgAgentApiKey(orgId);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down Expand Up @@ -559,7 +556,6 @@ export class IssuanceService {
const fileName = `${schemaResponse.tag}-${timestamp}.csv`;

await createFile(filePath, fileName, csv);
this.logger.log(`File created - ${fileName}`);
const fullFilePath = join(process.cwd(), `uploadedFiles/exports/${fileName}`);

if (!checkIfFileOrDirectoryExists(fullFilePath)) {
Expand All @@ -579,16 +575,11 @@ export class IssuanceService {


async importAndPreviewDataForIssuance(importFileDetails: ImportFileDetails): Promise<string> {
this.logger.log(`START importAndPreviewDataForIssuance----${JSON.stringify(importFileDetails)}`);
try {

const credDefResponse =
await this.issuanceRepository.getCredentialDefinitionDetails(importFileDetails.credDefId);

this.logger.log(`credDefResponse----${JSON.stringify(credDefResponse)}`);

this.logger.log(`csvFile::::::${JSON.stringify(importFileDetails.fileKey)}`);

const getFileDetails = await this.awsService.getFile(importFileDetails.fileKey);
const csvData: string = getFileDetails.Body.toString();

Expand All @@ -599,8 +590,6 @@ export class IssuanceService {
complete: (results) => results.data
});

this.logger.log(`parsedData----${JSON.stringify(parsedData)}`);

if (0 >= parsedData.data.length) {
throw new BadRequestException(`File data is empty`);
}
Expand Down Expand Up @@ -777,10 +766,8 @@ export class IssuanceService {
);
}

this.logger.log(`requestId----${JSON.stringify(requestId)}`);
try {
const cachedData = await this.cacheManager.get(requestId);
this.logger.log(`cachedData----${JSON.stringify(cachedData)}`);
if (!cachedData) {
throw new BadRequestException(ResponseMessages.issuance.error.cacheTimeOut);
}
Expand Down Expand Up @@ -821,7 +808,6 @@ export class IssuanceService {
}
for (const element of respFile) {
try {
this.logger.log(`element----${JSON.stringify(element)}`);
const payload = {
data: element.credential_data,
fileUploadId: element.fileUploadId,
Expand Down Expand Up @@ -873,7 +859,6 @@ export class IssuanceService {

for (const element of respFile) {
try {
this.logger.log(`element----${JSON.stringify(element)}`);
const payload = {
data: element.credential_data,
fileUploadId: element.fileUploadId,
Expand Down Expand Up @@ -924,7 +909,6 @@ export class IssuanceService {
detailError: '',
jobId: ''
};
this.logger.log(`jobDetails----${JSON.stringify(jobDetails)}`);

fileUploadData.fileUpload = jobDetails.fileUploadId;
fileUploadData.fileRow = JSON.stringify(jobDetails);
Expand Down Expand Up @@ -958,7 +942,7 @@ export class IssuanceService {
}
} catch (error) {
this.logger.error(
`error in issuanceBulkCredential for data ${JSON.stringify(jobDetails)} : ${JSON.stringify(error)}`
`error in issuanceBulkCredential for data : ${JSON.stringify(error)}`
);
fileUploadData.isError = true;
fileUploadData.error = JSON.stringify(error.error) ? JSON.stringify(error.error) : JSON.stringify(error);
Expand Down Expand Up @@ -989,9 +973,6 @@ export class IssuanceService {
lastChangedDateTime: new Date()
});

this.logger.log(`jobDetails.clientId----${JSON.stringify(jobDetails.clientId)}`);


}
} catch (error) {
this.logger.error(`Error in completing bulk issuance process: ${error}`);
Expand Down Expand Up @@ -1050,7 +1031,6 @@ export class IssuanceService {
});
return isFalsyForColumnValue;
});
this.logger.log(`isNullish: ${isNullish}`);
if (isNullish) {
throw new BadRequestException(
`Empty data found at row ${rowIndex} and column ${columnIndex}`
Expand Down
1 change: 0 additions & 1 deletion apps/organization/src/organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ export class OrganizationService {
const getAgent = await this.organizationRepository.getAgentEndPoint(orgId);
// const apiKey = await this._getOrgAgentApiKey(orgId);
let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY);
this.logger.log(`cachedApiKey----${apiKey}`);
if (!apiKey || null === apiKey || undefined === apiKey) {
apiKey = await this._getOrgAgentApiKey(orgId);
}
Expand Down
2 changes: 0 additions & 2 deletions apps/user/repositories/user-device.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class UserDevicesRepository {
* @returns Find device details from credentialID
*/
async getFidoUserDeviceDetails(credentialId: string): Promise<unknown> {
this.logger.log(`credentialId: ${credentialId}`);
try {
const getUserDevice = await this.prisma.$queryRaw`
SELECT * FROM user_devices
Expand Down Expand Up @@ -190,7 +189,6 @@ export class UserDevicesRepository {
*/
// eslint-disable-next-line camelcase
async checkUserDeviceByCredentialId(credentialId: string): Promise<user_devices> {
this.logger.log(`checkUserDeviceByCredentialId: ${credentialId}`);
try {
return await this.prisma.user_devices.findFirst({
where: {
Expand Down
1 change: 0 additions & 1 deletion apps/user/src/fido/fido.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export class FidoService {
.httpGet(url, { headers: { 'Content-Type': 'application/json' } })
.then(async (response) => {
const { user } = response;
this.logger.debug(`registration option:: already${JSON.stringify(response)}`);
await this.fidoUserRepository.updateUserDetails(email.toLowerCase(), [
{fidoUserId:user.id},
{isFidoVerified:false}
Expand Down
3 changes: 0 additions & 3 deletions libs/common/src/common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class CommonService {
.post(url, payload, apiKey)
.toPromise()
.then((response: any) => {
this.logger.log(`SUCCESS in POST : ${JSON.stringify(response.data)}`);
this.logger.error(response.data);
return response.data;
});
Expand Down Expand Up @@ -102,7 +101,6 @@ export class CommonService {
.get(url, config)
.toPromise()
.then((data) =>
// this.logger.log(`Success Data: ${JSON.stringify(data.data)}`);
data.data
);
} catch (error) {
Expand Down Expand Up @@ -171,7 +169,6 @@ export class CommonService {
.patch(url, payload, apiKey)
.toPromise()
.then((response: any) => {
this.logger.log(`SUCCESS in POST : ${JSON.stringify(response.data)}`);
return response.data;
});
} catch (error) {
Expand Down
7 changes: 6 additions & 1 deletion libs/enum/src/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ export enum UserCertificateId {
WORLD_RECORD = 'WorldRecord'
}

export enum NodeEnvironment {
DEVELOPMENT='DEV',
PRODUCTION='PROD'
}

const transitionMap: { [key in Invitation]: Invitation[] } = {
[Invitation.PENDING]: [Invitation.ACCEPTED, Invitation.REJECTED],
[Invitation.ACCEPTED]: [],
[Invitation.REJECTED]: []
};

export const transition = (currentStatus: Invitation, nextStatus: Invitation): boolean => (transitionMap[currentStatus].includes(nextStatus));
export const transition = (currentStatus: Invitation, nextStatus: Invitation): boolean => (transitionMap[currentStatus].includes(nextStatus));
2 changes: 0 additions & 2 deletions libs/org-roles/repositories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export class OrgRolesRepository {
description: true
}
});
this.logger.log(`In getroleDetails: ${JSON.stringify(roleDetails)}`);

return roleDetails;
} catch (error) {
this.logger.error(`In get org-roles by id repository : ${JSON.stringify(error)}`);
Expand Down