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: POST API response of send cred def to ledger #472

Merged
merged 2 commits into from
Jan 31, 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
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