mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-19 05:39:07 +00:00
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import {
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
OnModuleInit,
|
|
Param,
|
|
Post,
|
|
Put,
|
|
} from '@nestjs/common';
|
|
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
|
|
import { EnrichmentsService } 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: EnrichmentsService;
|
|
|
|
onModuleInit() {
|
|
this.enrichmentService =
|
|
this.enrichmentServiceClient.getService<EnrichmentsService>(
|
|
'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);
|
|
}
|
|
}
|