Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@ApiBearerAuth()
@ApiUseTags('products')
@Controller('products')
export class ProductController {
constructor(
private readonly productService: ProductService,
// private readonly redisService: RedisService
) {}
private readonly logger = new Logger(ProductController.name)
@ApiOperation({ title: 'Get all products' })
@ApiImplicitQuery({ name:'name', type: 'string', description:'product name',required: false})
@ApiResponse({ status: 200, description: 'Return all products.'})
@Get()
async findAll(@Query() query): Promise {
//use redis
// await this.redisService.set('foo','hehe')
// console.log(await this.redisService.get('foo'))
return await this.productService.findAll(query);
}
@ApiOperation({ title: 'Create product' })
@ApiResponse({ status: 201, description: 'The product has been successfully created.'})
@ApiResponse({ status: 403, description: 'Forbidden.' })
@UsePipes(new ValidationPipe({whitelist: true,forbidNonWhitelisted: true }))
@Post()
async create(@Body() productData:CreateProductDto) {
return this.productService.create(productData)
@Post('disconnect') // disconnect -> disconnectpeer
async executeDisconnect(@Body() dto: PeerNodeDto) {
return await this.ptarmiganService.requestTCP('disconnect', [dto.peerNodeId, '0.0.0.0', 0]);
}
@ApiBearerAuth()
@UseGuards(AuthGuard())
@Post('getlasterror') // getlasterror -> getlasterror
async executeGetLastErrort(@Body() dto: PeerNodeDto) {
return await this.ptarmiganService.requestTCP('getlasterror', [dto.peerNodeId, '0.0.0.0', 0]);
}
@ApiBearerAuth()
@UseGuards(AuthGuard())
@Post('dev-disautoconn') // disautoconn -> dev-disableautoconnect
@ApiImplicitQuery({
name: 'enable',
enum: [0, 1],
})
async executeDisAutoConn(@Query('enable') enable: number) {
return await this.ptarmiganService.requestTCP('disautoconn', [enable.toString(10)]);
}
@ApiBearerAuth()
@UseGuards(AuthGuard())
@Post('dev-listtransactions') // getcommittx -> dev-listtransactions
async executeGetCommitTx(@Body() dto: PeerNodeDto) {
return await this.ptarmiganService.requestTCP('getcommittx', [dto.peerNodeId, '0.0.0.0', 0]);
}
// ------------------------------------------------------------------------------
// channel
let object = await this.contentTypeRepository.findOneOrFail(id);
return plainToClass(OutContentTypeDto, object);
} catch (error) {
throw error;
}
}
@Roles('isSuperuser')
@Permissions('read_content-type')
@HttpCode(HttpStatus.OK)
@ApiResponse({
status: HttpStatus.OK, type: OutContentTypesDto,
description: ''
})
@ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })
@ApiImplicitQuery({ name: 'q', required: false, type: String, description: 'Text for search (default: empty)' })
@ApiImplicitQuery({
name: 'per_page', required: false, type: Number,
description: 'Number of results to return per page. (default: 10)'
})
@ApiImplicitQuery({
name: 'cur_page', required: false, type: Number,
description: 'A page number within the paginated result set. (default: 1)'
})
@Get()
async loadAll(
@Query('cur_page', new ParseIntWithDefaultPipe(1)) curPage,
@Query('per_page', new ParseIntWithDefaultPipe(10)) perPage,
@Query('q') q
) {
try {
const objects = await this.contentTypeRepository.findAndCount({
skip: (curPage - 1) * perPage,
description: ''
})
@ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })
@ApiImplicitQuery({
name: 'q',
required: false,
type: String,
description: 'Text for search (default: empty)'
})
@ApiImplicitQuery({
name: 'sort',
required: false,
type: String,
description: 'Column name for sort (default: -id)'
})
@ApiImplicitQuery({
name: 'per_page',
required: false,
type: Number,
description: 'Number of results to return per page. (default: 10)'
})
@ApiImplicitQuery({
name: 'cur_page',
required: false,
type: Number,
description: 'A page number within the paginated result set. (default: 1)'
})
@ApiImplicitQuery({
name: 'group',
required: false,
type: Number,
description: 'Group id for filter data by group. (default: empty)'
);
} catch (error) {
throw error;
}
}
@Roles('isSuperuser')
@Permissions('read_group')
@HttpCode(HttpStatus.OK)
@ApiResponse({
status: HttpStatus.OK,
type: OutGroupsDto,
description: ''
})
@ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })
@ApiImplicitQuery({
name: 'q',
required: false,
type: String,
description: 'Text for search (default: empty)'
})
@ApiImplicitQuery({
name: 'sort',
required: false,
type: String,
description: 'Column name for sort (default: -id)'
})
@ApiImplicitQuery({
name: 'per_page',
required: false,
type: Number,
description: 'Number of results to return per page. (default: 10)'
description: ''
})
@ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })
@ApiImplicitQuery({
name: 'q',
required: false,
type: String,
description: 'Text for search (default: empty)'
})
@ApiImplicitQuery({
name: 'sort',
required: false,
type: String,
description: 'Column name for sort (default: -id)'
})
@ApiImplicitQuery({
name: 'per_page',
required: false,
type: Number,
description: 'Number of results to return per page. (default: 10)'
})
@ApiImplicitQuery({
name: 'cur_page',
required: false,
type: Number,
description: 'A page number within the paginated result set. (default: 1)'
})
@ApiImplicitQuery({
name: 'group',
required: false,
type: Number,
description: 'Group id for filter data by group. (default: empty)'
description: ''
})
@ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })
@ApiImplicitQuery({
name: 'q',
required: false,
type: String,
description: 'Text for search (default: empty)'
})
@ApiImplicitQuery({
name: 'sort',
required: false,
type: String,
description: 'Column name for sort (default: -id)'
})
@ApiImplicitQuery({
name: 'per_page',
required: false,
type: Number,
description: 'Number of results to return per page. (default: 10)'
})
@ApiImplicitQuery({
name: 'cur_page',
required: false,
type: Number,
description: 'A page number within the paginated result set. (default: 1)'
})
@ApiImplicitQuery({
name: 'project',
required: false,
type: Number,
description: 'Project id for filter data by project. (default: empty)'