From ff40d2b77bb7b9024e2f6f7ecca097a5043e7af7 Mon Sep 17 00:00:00 2001 From: teetyff Date: Thu, 26 Mar 2026 23:19:52 +0100 Subject: [PATCH 1/2] fix: restore correct GovernanceService implementation --- backend/src/modules/governance/governance.service.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/backend/src/modules/governance/governance.service.ts b/backend/src/modules/governance/governance.service.ts index cb4765666..ba5a628bc 100644 --- a/backend/src/modules/governance/governance.service.ts +++ b/backend/src/modules/governance/governance.service.ts @@ -29,30 +29,21 @@ export class GovernanceService { async getUserVotingPower(userId: string): Promise { const user = await this.userService.findById(userId); - if (!user.publicKey) { return { votingPower: '0 NST' }; } - - // Get NST governance token contract ID from config const governanceTokenContractId = process.env.NST_GOVERNANCE_CONTRACT_ID; - if (!governanceTokenContractId) { throw new Error('NST governance token contract ID not configured'); } - - // Read balance from the NST governance token contract const balance = await this.savingsService.getUserVaultBalance( governanceTokenContractId, user.publicKey, ); - - // Convert to proper decimal representation (assuming 7 decimals like standard tokens) const votingPower = (balance / 10_000_000).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 0, }); - return { votingPower: `${votingPower} NST` }; } -} +} \ No newline at end of file From 00ad7b19bcd82339053173f1229f6f6cf4fef779 Mon Sep 17 00:00:00 2001 From: teetyff Date: Tue, 2 Jun 2026 08:18:34 +0100 Subject: [PATCH 2/2] feat: implement URI-based API versioning (v1) --- backend/src/main.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index b6247afee..a4e1ab080 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,5 +1,5 @@ import { NestFactory } from '@nestjs/core'; -import { ValidationPipe } from '@nestjs/common'; +import { ValidationPipe, VersioningType } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { AppModule } from './app.module'; import { AllExceptionsFilter } from './common/filters/http-exception.filter'; @@ -10,8 +10,12 @@ async function bootstrap() { const configService = app.get(ConfigService); const port = configService.get('port'); - app.setGlobalPrefix('api'); - app.useGlobalFilters(new AllExceptionsFilter()); + app.setGlobalPrefix('api'); + app.enableVersioning({ + type: VersioningType.URI, + defaultVersion: '1', + }); + app.useGlobalFilters(new AllExceptionsFilter()); app.useGlobalPipes( new ValidationPipe({ whitelist: true, @@ -20,18 +24,18 @@ async function bootstrap() { }), ); - // Swagger setup - const swaggerConfig = new DocumentBuilder() - .setTitle('Nestera API') - .setDescription('API documentation for the Nestera platform') - .setVersion('1.0') - .addBearerAuth() - .build(); + // Swagger setup + const swaggerConfig = new DocumentBuilder() + .setTitle('Nestera API') + .setDescription('API documentation for the Nestera platform (URI versioned, e.g., /v1/)') + .setVersion('1.0') + .addBearerAuth() + .build(); const document = SwaggerModule.createDocument(app, swaggerConfig); SwaggerModule.setup('api/docs', app, document); await app.listen(port || 3001); - console.log(`Application is running on: http://localhost:${port}/api`); - console.log(`Swagger docs available at: http://localhost:${port}/api/docs`); + console.log(`Application is running on: http://localhost:${port}/api (with URI versioning, e.g., /v1/)`); + console.log(`Swagger docs available at: http://localhost:${port}/api/docs (shows versioned endpoints)`); } bootstrap();