Skip to content
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
42 changes: 21 additions & 21 deletions src/modules/reputation/reputation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
export class ReputationController {
constructor(private readonly reputationService: ReputationService) { }

@Get('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Get reputation score for the authenticated user' })
@ApiResponse({
status: 200,
description: 'Reputation data retrieved successfully',
type: ReputationResponseDto,
})
@ApiResponse({ status: 401, description: 'Unauthorized — missing or invalid JWT' })
async getMyScore(@Request() req: any) {
const wallet = req.user?.wallet;
const data = await this.reputationService.getReputationScore(wallet);

return {
success: true,
data,
message: 'Your reputation data retrieved successfully',
};
}

@Get(':wallet')
@ApiOperation({ summary: 'Get reputation score for a specific wallet address' })
@ApiParam({
Expand Down Expand Up @@ -52,25 +73,4 @@ export class ReputationController {
message: 'Reputation data retrieved successfully',
};
}

@Get('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Get reputation score for the authenticated user' })
@ApiResponse({
status: 200,
description: 'Reputation data retrieved successfully',
type: ReputationResponseDto,
})
@ApiResponse({ status: 401, description: 'Unauthorized — missing or invalid JWT' })
async getMyScore(@Request() req: any) {
const wallet = req.user?.wallet;
const data = await this.reputationService.getReputationScore(wallet);

return {
success: true,
data,
message: 'Your reputation data retrieved successfully',
};
}
}
21 changes: 21 additions & 0 deletions test/__mocks__/stellar-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ module.exports = {
fromSecret: jest.fn(() => ({
publicKey: jest.fn(() => 'GABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVW'),
})),
fromPublicKey: jest.fn(() => ({
verify: jest.fn(() => true),
publicKey: jest.fn(() => 'GABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVW'),
})),
random: jest.fn(() => ({
sign: jest.fn(() => Buffer.alloc(64)),
verify: jest.fn(() => true),
publicKey: jest.fn(() => 'GABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVW'),
secret: jest.fn(() => 'SABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
})),
},
Account: jest.fn((publicKey, sequence) => ({
accountId: () => publicKey,
sequenceNumber: () => sequence,
})),
StrKey: {
isValidEd25519PublicKey: jest.fn(() => true),
isValidEd25519SecretSeed: jest.fn(() => true),
Expand All @@ -32,6 +42,17 @@ module.exports = {
getTransaction: jest.fn(),
})),
},
Horizon: {
Server: jest.fn(() => ({
loadAccount: jest.fn(),
submitTransaction: jest.fn(),
transactions: jest.fn(() => ({
transaction: jest.fn(() => ({
call: jest.fn().mockResolvedValue({}),
})),
})),
})),
},
BASE_FEE: '100',
Networks: {
PUBLIC: 'Public Global Stellar Network ; September 2015',
Expand Down
Loading
Loading