Skip to content

Commit

Permalink
Merge pull request #472 from credebl/send-cred-def-to-ledger
Browse files Browse the repository at this point in the history
fix: POST API response of send cred def to ledger
  • Loading branch information
vivekayanworks authored Jan 31, 2024
2 parents 70a40d2 + 990b0e8 commit 3160b3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { UnauthorizedErrorDto } from 'apps/api-gateway/src/dtos/unauthorized-err
import { ForbiddenErrorDto } from 'apps/api-gateway/src/dtos/forbidden-error.dto';
import { User } from '../authz/decorators/user.decorator';
import { AuthGuard } from '@nestjs/passport';
import IResponseType from '@credebl/common/interfaces/response.interface';
import IResponseType, { IResponse } from '@credebl/common/interfaces/response.interface';
import { ResponseMessages } from '@credebl/common/response-messages';
import { Response } from 'express';
import { GetAllCredDefsDto } from './dto/get-all-cred-defs.dto';
Expand Down Expand Up @@ -128,14 +128,14 @@ export class CredentialDefinitionController {
@Body() credDef: CreateCredentialDefinitionDto,
@Param('orgId') orgId: string,
@Res() res: Response
): Promise<object> {
): Promise<Response> {

credDef.orgId = orgId;
const credentialsDefinitionDetails = await this.credentialDefinitionService.createCredentialDefinition(credDef, user);
const credDefResponse: IResponseType = {
const credDefResponse: IResponse = {
statusCode: HttpStatus.CREATED,
message: ResponseMessages.credentialDefinition.success.create,
data: credentialsDefinitionDetails.response
data: credentialsDefinitionDetails
};
return res.status(HttpStatus.CREATED).json(credDefResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export class CredentialDefinitionService extends BaseService {
super('CredentialDefinitionService');
}

createCredentialDefinition(credDef: CreateCredentialDefinitionDto, user: IUserRequestInterface): Promise<{ response: object }> {
createCredentialDefinition(credDef: CreateCredentialDefinitionDto, user: IUserRequestInterface): Promise<object> {
const payload = { credDef, user };

return this.sendNats(this.credDefServiceProxy, 'create-credential-definition', payload);
return this.sendNatsMessage(this.credDefServiceProxy, 'create-credential-definition', payload);
}

getCredentialDefinitionById(credentialDefinitionId: string, orgId: string): Promise<{ response: object }> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export class CredentialDefinitionService extends BaseService {
credDefData.lastChangedBy = userId;
}
const credDefResponse = await this.credentialDefinitionRepository.saveCredentialDefinition(credDefData);

delete credDefResponse.lastChangedBy;
delete credDefResponse.lastChangedDateTime;

return credDefResponse;

} catch (error) {
Expand Down

0 comments on commit 3160b3b

Please sign in to comment.