All files / src/domains/projects/controllers client-project.controller.ts

0% Statements 0/15
0% Branches 0/16
0% Functions 0/2
0% Lines 0/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                                                     
import { Controller, Get, Param, Req } from '@nestjs/common';
import { ProjectService } from '../services/project.service';
import { ProjectBudgetService } from '../services/project-budget.service';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
/**
 * CLIENT FACING PORTAL CONTROLLER
 * This controller explicitly scrubs internal data before returning.
 */
@Controller('api/v1/client/projects')
@ApiTags('ClientProject')
export class ClientProjectController {
  constructor(
    private readonly projectService: ProjectService,
    private readonly budgetService: ProjectBudgetService,
  ) {}
 
  @Get(':id')
  @ApiOperation({ summary: 'Get project details operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async getProjectDetails(
    @Req() req: any,
    @Param('id') id: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    const project = await this.projectService.findOne(tenantId, id);
 
    // Explicitly hide internal costing metrics
    const safeProject = project.toObject ? project.toObject() : project;
    delete safeProject.progressMetrics; // Hide internal metrics
 
    return safeProject;
  }
}