Browse Source

Address PR review feedback

- Add changelog entry under Unreleased → Added
- Introduce PlatformsResponse interface for extensibility
- Update controller to return { platforms: Platform[] } structure
- Add readPlatforms permission to ADMIN role
pull/6097/head
0pilatos0 1 month ago
parent
commit
11127bb878
  1. 4
      CHANGELOG.md
  2. 8
      apps/api/src/app/endpoints/platforms/platforms.controller.ts
  3. 2
      libs/common/src/lib/interfaces/index.ts
  4. 5
      libs/common/src/lib/interfaces/responses/platforms-response.interface.ts
  5. 1
      libs/common/src/lib/permissions.ts

4
CHANGELOG.md

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Added a new endpoint to get all platforms (`GET api/v1/platforms`)
### Changed
- Lifted the asset profile identifier editing restriction for `MANUAL` data sources in the asset profile details dialog of the admin control panel

8
apps/api/src/app/endpoints/platforms/platforms.controller.ts

@ -1,11 +1,11 @@
import { HasPermission } from '@ghostfolio/api/decorators/has-permission.decorator';
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard';
import { PlatformService } from '@ghostfolio/api/app/platform/platform.service';
import { PlatformsResponse } from '@ghostfolio/common/interfaces';
import { permissions } from '@ghostfolio/common/permissions';
import { Controller, Get, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { Platform } from '@prisma/client';
@Controller('platforms')
export class PlatformsController {
@ -14,7 +14,9 @@ export class PlatformsController {
@Get()
@HasPermission(permissions.readPlatforms)
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
public async getPlatforms(): Promise<Platform[]> {
return this.platformService.getPlatforms();
public async getPlatforms(): Promise<PlatformsResponse> {
const platforms = await this.platformService.getPlatforms();
return { platforms };
}
}

2
libs/common/src/lib/interfaces/index.ts

@ -68,6 +68,7 @@ import type { LookupResponse } from './responses/lookup-response.interface';
import type { MarketDataDetailsResponse } from './responses/market-data-details-response.interface';
import type { MarketDataOfMarketsResponse } from './responses/market-data-of-markets-response.interface';
import type { OAuthResponse } from './responses/oauth-response.interface';
import type { PlatformsResponse } from './responses/platforms-response.interface';
import type { PortfolioDividendsResponse } from './responses/portfolio-dividends-response.interface';
import type { PortfolioHoldingResponse } from './responses/portfolio-holding-response.interface';
import type { PortfolioHoldingsResponse } from './responses/portfolio-holdings-response.interface';
@ -158,6 +159,7 @@ export {
MarketDataDetailsResponse,
MarketDataOfMarketsResponse,
OAuthResponse,
PlatformsResponse,
PortfolioChart,
PortfolioDetails,
PortfolioDividendsResponse,

5
libs/common/src/lib/interfaces/responses/platforms-response.interface.ts

@ -0,0 +1,5 @@
import { Platform } from '@prisma/client';
export interface PlatformsResponse {
platforms: Platform[];
}

1
libs/common/src/lib/permissions.ts

@ -93,6 +93,7 @@ export function getPermissions(aRole: Role): string[] {
permissions.readAiPrompt,
permissions.readMarketData,
permissions.readMarketDataOfOwnAssetProfile,
permissions.readPlatforms,
permissions.readPlatformsWithAccountCount,
permissions.readTags,
permissions.readWatchlist,

Loading…
Cancel
Save