import { DynamicLoader } from '@app/event-emitter/configs/dynamic-loader'; import { Controller, Get, Param, Render } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { IssuesByTagsWidgetService } from './widgets/issues-by-tags.widget.service'; import { parse } from 'jsonc-parser'; @Controller('simple-issues-list') export class SimpleIssuesListController { private path: string; constructor( private issuesByTagsWidgetService: IssuesByTagsWidgetService, private dynamicLoader: DynamicLoader, private configService: ConfigService, ) { this.path = this.configService.get('simpleKanbanBoard.path'); } @Get('/by-tags/:name/raw') async getByTagsRawData(@Param('name') name: string): Promise { const cfg = this.dynamicLoader.load(name, { path: this.path, ext: 'jsonc', parser: parse, }); return await this.issuesByTagsWidgetService.render(cfg); } @Get('/by-tags/:name') @Render('simple-issues-list') async getByTags(@Param('name') name: string): Promise { return await this.getByTagsRawData(name); } }