mirror of
https://github.com/dadosfera/maestro.git
synced 2026-08-31 19:58:21 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { Controller, Delete, Get, OnModuleInit, Param, Post, Put } from '@nestjs/common';
|
|
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
|
|
import { EnrichmentGrpcClientService } from './enrichment.service';
|
|
import { CreateEnrichmentDto } from './dto/create-enrichment.dto';
|
|
import { UpdateEnrichmentDto } from './dto/update-enrichment.dto';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { GrpcClientConfiguration } from './config/grpc-client';
|
|
|
|
@ApiTags('enrichments')
|
|
@Controller('enrichment')
|
|
export class EnrichmentController implements OnModuleInit {
|
|
|
|
|
|
|
|
@Client(GrpcClientConfiguration)
|
|
private enrichmentServiceClient: ClientGrpc;
|
|
|
|
private enrichmentService: EnrichmentGrpcClientService;
|
|
|
|
onModuleInit() {
|
|
this.enrichmentService =
|
|
this.enrichmentServiceClient.getService<EnrichmentGrpcClientService>('EnrichmentService');
|
|
}
|
|
|
|
@Post()
|
|
create(@Payload() createEnrichmentDto: CreateEnrichmentDto) {
|
|
return this.enrichmentService.create(createEnrichmentDto);
|
|
}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.enrichmentService.list();
|
|
}
|
|
|
|
@Get(':id')
|
|
show(@Param() id: string) {
|
|
return this.enrichmentService.show(id);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(@Param() id:string,@Payload() updateEnrichmentDto: UpdateEnrichmentDto) {
|
|
return this.enrichmentService.update(id, updateEnrichmentDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param() id: string) {
|
|
return this.enrichmentService.remove(id);
|
|
}
|
|
}
|