| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 35 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | 6 | import { Body, Controller, Get, Post } from '@nestjs/common'; |
|
| 2 | 6 | import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; |
|
| 3 | 6 | import { CitiesService } from './cities.service'; |
|
| 4 | 6 | import { CreateCityDto } from './dto/create-city.dto'; |
|
| 5 | import { CityName } from './types/city.enum'; |
||
|
|
|||
| 6 | 6 | import { City } from './entities/city.entity'; |
|
| 7 | |||
| 8 | @ApiTags('Cities') |
||
| 9 | @Controller({ path: 'cities', version: '1' }) |
||
| 10 | 6 | export class CitiesController { |
|
| 11 | 3 | constructor(private readonly citiesService: CitiesService) {} |
|
| 12 | |||
| 13 | @Get() |
||
| 14 | @ApiOperation({ summary: 'Get all cities' }) |
||
| 15 | @ApiResponse({ |
||
| 16 | status: 200, |
||
| 17 | description: 'List of bicycles', |
||
| 18 | type: [City], |
||
| 19 | }) |
||
| 20 | 6 | async getAllCities() { |
|
| 21 | 1 | return await this.citiesService.findAll(); |
|
| 22 | } |
||
| 23 | |||
| 24 | @Post('create') |
||
| 25 | @ApiOperation({ summary: 'Create a new city' }) |
||
| 26 | @ApiResponse({ |
||
| 27 | status: 201, |
||
| 28 | description: 'City created successfully', |
||
| 29 | type: City, |
||
| 30 | }) |
||
| 31 | 6 | async createACity(@Body() createCityDto: CreateCityDto) { |
|
| 32 | 1 | return await this.citiesService.createCity(createCityDto); |
|
| 33 | } |
||
| 34 | } |
||
| 35 |