mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-11 23:24:47 +00:00
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import {
|
|
Get,
|
|
Post,
|
|
Controller,
|
|
Delete,
|
|
OnModuleInit,
|
|
Put,
|
|
Param
|
|
} from '@nestjs/common';
|
|
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
|
|
import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
|
import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
|
import { InputGrpcClientService } from './input-grpc-client.service';
|
|
import { GrpcClientConfiguration } from './config/grpc-client';
|
|
import { TestConnectionDTO } from './dto/test-connection-grpc-client.dto';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
@Controller('grpc/input')
|
|
export class InputGrpcClientController implements OnModuleInit {
|
|
@Client(GrpcClientConfiguration)
|
|
private inputServiceClient: ClientGrpc;
|
|
|
|
private inputService: InputGrpcClientService;
|
|
|
|
onModuleInit() {
|
|
this.inputService =
|
|
this.inputServiceClient.getService<InputGrpcClientService>('InputService');
|
|
}
|
|
|
|
@Post()
|
|
async create(@Payload() createInputDto: CreateInputGrpcClientDto) {
|
|
return this.inputService.create(createInputDto);
|
|
}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.inputService.list();
|
|
}
|
|
|
|
@Get(':id')
|
|
show(@Param() id: string) {
|
|
return this.inputService.show(id);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(
|
|
@Payload() updateInputDto: UpdateInputGrpcClientDto,
|
|
@Param() id: string,
|
|
) {
|
|
return this.inputService.update(id, updateInputDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param() id: string) {
|
|
return this.inputService.remove(id);
|
|
}
|
|
|
|
@Get('/test-connection')
|
|
testConnection(@Payload() testConnectionDTO:TestConnectionDTO){
|
|
|
|
return this.inputService.testConnection(testConnectionDTO)
|
|
}
|
|
}
|