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 | 2x 2x 2x 2x 2x 2x 4x 2x 1x 2x 1x 2x 1x | import {
Body,
Controller,
Get,
Param,
ParseUUIDPipe,
Post,
Query,
} from '@nestjs/common';
import {
ApiBearerAuth,
ApiBody,
ApiCreatedResponse,
ApiForbiddenResponse,
ApiOkResponse,
ApiOperation,
ApiQuery,
ApiTags,
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { Roles } from '../../auth/auth.decorators';
import { PropertiesClient } from '../clients/properties.client';
import {
CreatePropertyRequest,
Paginated,
PropertyDto,
PropertyPage,
} from '../http/api-types';
@ApiTags('properties')
@ApiBearerAuth()
@ApiUnauthorizedResponse({ description: 'Missing or invalid token' })
@ApiForbiddenResponse({ description: 'Role not allowed on this route' })
@Controller('properties')
export class PropertiesController {
constructor(private readonly properties: PropertiesClient) {}
@ApiOperation({
summary: 'Register a property',
description: 'Roles: manager.',
})
@ApiBody({ type: CreatePropertyRequest })
@ApiCreatedResponse({ type: PropertyDto })
@Roles('manager')
@Post()
create(@Body() body: unknown): Promise<PropertyDto> {
return this.properties.create(body);
}
@ApiOperation({
summary: 'List properties',
description: 'Roles: any authenticated user.',
})
@ApiQuery({ name: 'page', required: false, example: 1 })
@ApiQuery({ name: 'limit', required: false, example: 20 })
@ApiOkResponse({ type: PropertyPage })
@Get()
list(
@Query() query: Record<string, string>,
): Promise<Paginated<PropertyDto>> {
return this.properties.list(query);
}
@ApiOperation({
summary: 'Get one property',
description: 'Roles: any authenticated user.',
})
@ApiOkResponse({ type: PropertyDto })
@Get(':id')
getById(@Param('id', ParseUUIDPipe) id: string): Promise<PropertyDto> {
return this.properties.getById(id);
}
}
|