import { Controller, Get } from '@nestjs/common';
import { DashboardsService } from './dashboards.service';
import { BadRequestErrorHandler, getOrAppErrorOrThrow } from '../utils/result';
import { UNLIMITED } from '../consts/consts';

@Controller('api/dashboards')
export class DashboardsController {
  constructor(private dashboardsService: DashboardsService) {}

  @Get()
  async list(): Promise<any> {
    const res = await getOrAppErrorOrThrow(
      () => this.dashboardsService.publicList(UNLIMITED),
      BadRequestErrorHandler,
    );
    return res;
  }
}
