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