35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { Request } from 'express';
|
|
|
|
import { Controller, Get, Param, Req, UseGuards } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
|
|
|
import { ApiProblemResponses } from '#src/common/decorators/api-safe-error-response.decorator';
|
|
import { AccessPayload, JwtAuthGuard } from '#src/modules/auth/auth.api';
|
|
|
|
import { PortfolioService } from '../application/portfolio.service';
|
|
import { PortfolioResourceDto } from './portfolio.dto';
|
|
|
|
@ApiTags('brokerage-accounts')
|
|
@ApiProblemResponses()
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
@Controller('brokerage-accounts')
|
|
export class PortfolioController {
|
|
constructor(private readonly portfolio: PortfolioService) {}
|
|
|
|
@Get('all/portfolio')
|
|
@ApiOkResponse({ type: PortfolioResourceDto })
|
|
all(@Req() request: Request & { user: AccessPayload }) {
|
|
return this.portfolio.read(request.user.sub, 'all');
|
|
}
|
|
|
|
@Get(':accountId/portfolio')
|
|
@ApiOkResponse({ type: PortfolioResourceDto })
|
|
get(
|
|
@Req() request: Request & { user: AccessPayload },
|
|
@Param('accountId') accountId: string,
|
|
) {
|
|
return this.portfolio.read(request.user.sub, accountId);
|
|
}
|
|
}
|