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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import {
Controller,
Get,
Post,
Body,
Param,
Put,
Delete,
ParseUUIDPipe,
HttpCode,
HttpStatus,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { ProjectsService } from './projects.service';
import { CreateProjectDto, UpdateProjectDto } from './dto/project.dto';
import { Project } from '../core-entities';
@ApiTags('projects')
@Controller('projects')
export class ProjectsController {
constructor(private readonly projectsService: ProjectsService) {}
@Post()
@ApiOperation({ summary: 'Create a new project' })
@ApiResponse({
status: 201,
description: 'Project created successfully',
type: Project,
})
async create(@Body() createProjectDto: CreateProjectDto): Promise<Project> {
return this.projectsService.create(createProjectDto);
}
@Get()
@ApiOperation({ summary: 'List all projects' })
@ApiResponse({
status: 200,
description: 'List of projects',
type: [Project],
})
async findAll(): Promise<Project[]> {
return this.projectsService.findAll();
}
@Get(':id')
@ApiOperation({ summary: 'Get a project by ID' })
@ApiParam({ name: 'id', description: 'Project UUID', format: 'uuid' })
@ApiResponse({ status: 200, description: 'Project found', type: Project })
@ApiResponse({ status: 404, description: 'Project not found' })
async findOne(@Param('id', ParseUUIDPipe) id: string): Promise<Project> {
return this.projectsService.findOne(id);
}
@Put(':id')
@ApiOperation({ summary: 'Update a project' })
@ApiParam({ name: 'id', description: 'Project UUID', format: 'uuid' })
@ApiResponse({
status: 200,
description: 'Project updated successfully',
type: Project,
})
@ApiResponse({ status: 404, description: 'Project not found' })
async update(
@Param('id', ParseUUIDPipe) id: string,
@Body() updateProjectDto: UpdateProjectDto,
): Promise<Project> {
return this.projectsService.update(id, updateProjectDto);
}
@Delete(':id')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Delete a project' })
@ApiParam({ name: 'id', description: 'Project UUID', format: 'uuid' })
@ApiResponse({ status: 204, description: 'Project deleted successfully' })
@ApiResponse({ status: 404, description: 'Project not found' })
async remove(@Param('id', ParseUUIDPipe) id: string): Promise<void> {
return this.projectsService.remove(id);
}
}
|