moex-vibe/apps/backend/src/modules/shares/shares.controller.ts
Sergey Krylov 5b794c0419 feat: add Swagger response DTOs for all missing endpoints
- Shares: ShareEnvelopeDto, ShareMarketDataEnvelopeDto, DividendsEnvelopeDto,
  ShareHistoryEnvelopeDto, DividendItemDto, HistoryItemDto
- Bonds: BondEnvelopeDto, BondMarketDataEnvelopeDto, BondHistoryEnvelopeDto,
  BondHistoryItemDto
- Candles: CandleItemDto, CandleEnvelopeDto
- Securities: SearchResultItemDto, SearchEnvelopeDto
- Health: HealthResponseDto, HealthEnvelopeDto
- Add @ApiOkResponse decorators to all previously undocumented endpoints
- Reuse ApiResponseMeta from common for all envelope DTOs
2026-06-23 07:17:30 +03:00

51 lines
1.8 KiB
TypeScript

import { Controller, Get, Param, Query } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiOkResponse, ApiExtraModels } from '@nestjs/swagger';
import { ApiResponseMeta } from '../../common/dto/api-response.dto';
import { SharesService } from './shares.service';
import {
ShareEnvelopeDto,
ShareMarketDataEnvelopeDto,
DividendsEnvelopeDto,
ShareHistoryEnvelopeDto,
} from './dto/shares-envelope.dto';
@ApiTags('Shares')
@ApiExtraModels(ApiResponseMeta)
@Controller('securities/shares')
export class SharesController {
constructor(private readonly sharesService: SharesService) {}
@Get(':secid')
@ApiOperation({ summary: 'Получить спецификацию акции' })
@ApiOkResponse({ type: ShareEnvelopeDto })
async getShare(@Param('secid') secid: string) {
const share = await this.sharesService.getShare(secid);
return { data: share, meta: { cachedAt: null, fromCache: false } };
}
@Get(':secid/marketdata')
@ApiOperation({ summary: 'Получить рыночные данные акции' })
@ApiOkResponse({ type: ShareMarketDataEnvelopeDto })
async getMarketData(@Param('secid') secid: string) {
return this.sharesService.getMarketData(secid);
}
@Get(':secid/dividends')
@ApiOperation({ summary: 'Получить дивиденды' })
@ApiOkResponse({ type: DividendsEnvelopeDto })
async getDividends(@Param('secid') secid: string) {
return this.sharesService.getDividends(secid);
}
@Get(':secid/history')
@ApiOperation({ summary: 'Получить дневную историю торгов акции' })
@ApiOkResponse({ type: ShareHistoryEnvelopeDto })
async getHistory(
@Param('secid') secid: string,
@Query('from') from: string,
@Query('till') till: string,
) {
return this.sharesService.getHistory(secid, from, till);
}
}