Skip to content

Commit

Permalink
added logger
Browse files Browse the repository at this point in the history
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
tipusinghaw authored and KulkarniShashank committed Sep 11, 2024
1 parent d516ba1 commit a928599
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ async downloadBulkIssuanceCSVTemplate(
};

const importCsvDetails = await this.issueCredentialService.uploadCSVTemplate(uploadedfileDetails);
this.logger.log("importCsvDetails:", importCsvDetails);
const finalResponse: IResponseType = {
statusCode: HttpStatus.CREATED,
message: ResponseMessages.issuance.success.importCSV,
Expand Down
18 changes: 13 additions & 5 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
transformheader: (header) => header.toLowerCase().replace('#', '').trim(),
complete: (results) => results.data
});
this.logger.log("parsedData:", parsedData);

if (0 >= parsedData.data.length) {
throw new BadRequestException(ResponseMessages.bulkIssuance.error.emptyFile);
Expand All @@ -1031,24 +1032,30 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
throw new BadRequestException(ResponseMessages.bulkIssuance.error.emptyheader);
}
const invalidEmails = parsedData.data.filter((entry) => !validateEmail(entry.email_identifier));
this.logger.log("invalidEmails:", invalidEmails);
if (0 < invalidEmails.length) {
throw new BadRequestException(ResponseMessages.bulkIssuance.error.invalidEmails);
}
const fileData: string[][] = parsedData.data.map(Object.values);
const fileHeader: string[] = parsedData.meta.fields;

this.logger.log("fileData:", fileData);
this.logger.log('fileHeader:', fileHeader);
const attributesArray = JSON.parse(credentialDetails.attributes);
this.logger.log('attributesArray:', attributesArray);

// Extract the 'attributeName' values from the objects and store them in an array
const attributeNameArray = attributesArray.map(attribute => attribute.attributeName);
this.logger.log("attributeNameArray:", attributeNameArray);
if (0 >= attributeNameArray.length) {
throw new BadRequestException(
`Attributes are empty for credential definition ${templateId}`
);
}

await this.validateFileHeaders(fileHeader, attributeNameArray);
await this.validateFileData(fileData, attributesArray, fileHeader);
const validateFileHeaders = await this.validateFileHeaders(fileHeader, attributeNameArray);
const validateFileData = await this.validateFileData(fileData, attributesArray, fileHeader);
this.logger.log("validateFileHeaders:", validateFileHeaders);
this.logger.log("validateFileData:", validateFileData);

const resData = {
schemaLedgerId: credDefResponse.schemaLedgerId,
Expand All @@ -1059,8 +1066,9 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO

const newCacheKey = uuidv4();

await this.cacheManager.set(requestId ? requestId : newCacheKey, JSON.stringify(credentialPayload), 60000);

const cacheManager = await this.cacheManager.set(requestId ? requestId : newCacheKey, JSON.stringify(credentialPayload), 60000);
this.logger.log("cacheManager:", cacheManager);
this.logger.log("newCacheKey:", newCacheKey);
return newCacheKey;

} catch (error) {
Expand Down

0 comments on commit a928599

Please sign in to comment.