mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-01 10:29:08 +00:00
@@ -0,0 +1,90 @@
|
||||
name: Deploy
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- stg
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v2
|
||||
id: semantic
|
||||
with:
|
||||
semantic_version: 16
|
||||
extra_plugins: |
|
||||
@semantic-release/changelog
|
||||
@semantic-release/git
|
||||
conventional-changelog-eslint
|
||||
branches: |
|
||||
['main']
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Update Pip
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
python3 -m pip install docker-compose --upgrade
|
||||
|
||||
- name: Install AWS CLI
|
||||
run: |
|
||||
python3 -m pip install awscli --upgrade
|
||||
|
||||
- name: Install AWS Elastic Beanstalk ClI
|
||||
run: |
|
||||
python3 -m pip install awsebcli --upgrade
|
||||
|
||||
- name: Configure AWS Region
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Extract Environment
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
echo "##[set-output name=result;]$(echo "prd")"
|
||||
else
|
||||
echo "##[set-output name=result;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||
fi
|
||||
id: extract_environment
|
||||
|
||||
- name: Login to AWS ECR
|
||||
id: login_ecr
|
||||
uses: aws-actions/amazon-ecr-login@v1
|
||||
|
||||
- name: Build, Tag, and Push Image to AWS ECR
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
IMAGE_TAG: latest
|
||||
run: |
|
||||
export ENV=$ENV
|
||||
docker-compose -f build.docker-compose.yml build
|
||||
docker-compose -f build.docker-compose.yml push
|
||||
|
||||
- name: Create ZIP file to Deploy AWS Beanstalk
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
run: |
|
||||
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
|
||||
zip deploy.zip docker-compose.yml
|
||||
|
||||
- name: Deploy AWS Beanstalk
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
AWS_REGION: us-east-1
|
||||
APP_NAME: maestro
|
||||
run: |
|
||||
printf "n" | eb init $APP_NAME --region $AWS_REGION
|
||||
eb use $APP_NAME-$ENV
|
||||
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
||||
eb deploy
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Test
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
- stg
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
python3 -m pip install docker-compose --upgrade
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
IMAGE_TAG: latest
|
||||
run: |
|
||||
export ENV=test
|
||||
docker-compose -f build.docker-compose.yml build
|
||||
|
||||
- name: Run Test
|
||||
run: |
|
||||
export ENV=test
|
||||
docker-compose run --rm --entrypoint="npm run test" maestro
|
||||
@@ -36,3 +36,8 @@ lerna-debug.log*
|
||||
|
||||
# Ignore .env files
|
||||
*.env
|
||||
|
||||
# Elastic Beanstalk Files
|
||||
.elasticbeanstalk/*
|
||||
!.elasticbeanstalk/*.cfg.yml
|
||||
!.elasticbeanstalk/*.global.yml
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"branch": "dev",
|
||||
"plugins": [
|
||||
[
|
||||
"@semantic-release/commit-analyzer",
|
||||
{
|
||||
"preset": "eslint",
|
||||
"releaseRules": [
|
||||
{ "tag": "Breaking", "release": "major" },
|
||||
{ "tag": "Build", "release": "minor" },
|
||||
{ "tag": "Chore", "release": "minor" },
|
||||
{ "tag": "Fix", "release": "patch" },
|
||||
{ "tag": "New", "release": "minor" },
|
||||
{ "tag": "Update", "release": "minor" },
|
||||
{ "tag": "Upgrade", "release": "minor" }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/release-notes-generator",
|
||||
{
|
||||
"preset": "eslint",
|
||||
"releaseRules": [
|
||||
{ "tag": "Breaking", "release": "major" },
|
||||
{ "tag": "Build", "release": "minor" },
|
||||
{ "tag": "Chore", "release": "minor" },
|
||||
{ "tag": "Fix", "release": "patch" },
|
||||
{ "tag": "New", "release": "minor" },
|
||||
{ "tag": "Update", "release": "minor" },
|
||||
{ "tag": "Upgrade", "release": "minor" }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
"changelogFile": "CHANGELOG.md"
|
||||
}
|
||||
],
|
||||
"@semantic-release/github",
|
||||
[
|
||||
"@semantic-release/git", {
|
||||
"assets": ["package.json", "CHANGELOG.md"],
|
||||
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
maestro:
|
||||
build: .
|
||||
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:latest
|
||||
@@ -0,0 +1,27 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
maestro:
|
||||
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:latest
|
||||
container_name: maestro
|
||||
restart: always
|
||||
ports:
|
||||
- 3333:3333
|
||||
|
||||
node_exporter:
|
||||
image: prom/node-exporter:v1.3.1
|
||||
container_name: node_exporter
|
||||
restart: always
|
||||
volumes:
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
- /:/rootfs:ro
|
||||
- /run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
|
||||
command:
|
||||
- '--path.procfs=/host/proc'
|
||||
- '--path.rootfs=/rootfs'
|
||||
- '--path.sysfs=/host/sys'
|
||||
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
|
||||
- '--collector.systemd'
|
||||
- '--collector.processes'
|
||||
network_mode: host
|
||||
pid: host
|
||||
Generated
+7258
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { EnrichmentController } from './enrichment.controller';
|
||||
import { EnrichmentGrpcClientService } from './enrichment.service';
|
||||
import { EnrichmentsService } from './enrichment.service';
|
||||
|
||||
describe('EnrichmentController', () => {
|
||||
let controller: EnrichmentController;
|
||||
@@ -8,7 +8,7 @@ describe('EnrichmentController', () => {
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [EnrichmentController],
|
||||
providers: [EnrichmentGrpcClientService],
|
||||
providers: [EnrichmentsService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<EnrichmentController>(EnrichmentController);
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { Controller, Delete, Get, OnModuleInit, Param, Post, Put } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
|
||||
import { EnrichmentGrpcClientService } from './enrichment.service';
|
||||
import { EnrichmentsService } from './enrichment.service';
|
||||
import { CreateEnrichmentDto } from './dto/create-enrichment.dto';
|
||||
import { UpdateEnrichmentDto } from './dto/update-enrichment.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
@@ -10,16 +18,16 @@ import { GrpcClientConfiguration } from './config/grpc-client';
|
||||
@Controller('enrichment')
|
||||
export class EnrichmentController implements OnModuleInit {
|
||||
|
||||
|
||||
|
||||
@Client(GrpcClientConfiguration)
|
||||
private enrichmentServiceClient: ClientGrpc;
|
||||
|
||||
private enrichmentService: EnrichmentGrpcClientService;
|
||||
private enrichmentService: EnrichmentsService;
|
||||
|
||||
onModuleInit() {
|
||||
this.enrichmentService =
|
||||
this.enrichmentServiceClient.getService<EnrichmentGrpcClientService>('EnrichmentService');
|
||||
this.enrichmentServiceClient.getService<EnrichmentsService>(
|
||||
'EnrichmentService',
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@@ -38,7 +46,10 @@ export class EnrichmentController implements OnModuleInit {
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
update(@Param() id:string,@Payload() updateEnrichmentDto: UpdateEnrichmentDto) {
|
||||
update(
|
||||
@Param() id: string,
|
||||
@Payload() updateEnrichmentDto: UpdateEnrichmentDto,
|
||||
) {
|
||||
return this.enrichmentService.update(id, updateEnrichmentDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { EnrichmentGrpcClientService } from './enrichment.service';
|
||||
import { EnrichmentsService } from './enrichment.service';
|
||||
import { EnrichmentController } from './enrichment.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [EnrichmentController],
|
||||
providers: [EnrichmentGrpcClientService]
|
||||
providers: [EnrichmentsService],
|
||||
})
|
||||
export class EnrichmentModule {}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { EnrichmentService } from './enrichment.service';
|
||||
import { EnrichmentsService } from './enrichment.service';
|
||||
|
||||
describe('EnrichmentService', () => {
|
||||
let service: EnrichmentService;
|
||||
let service: EnrichmentsService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [EnrichmentService],
|
||||
providers: [EnrichmentsService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<EnrichmentService>(EnrichmentService);
|
||||
service = module.get<EnrichmentsService>(EnrichmentsService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreateEnrichmentDto } from './dto/create-enrichment.dto';
|
||||
import { UpdateEnrichmentDto } from './dto/update-enrichment.dto';
|
||||
|
||||
@Injectable()
|
||||
export class EnrichmentGrpcClientService {
|
||||
export class EnrichmentsService {
|
||||
create(createEnrichmentDto: CreateEnrichmentDto) {
|
||||
return 'This action adds a new enrichment';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { OutputsController } from './outputs.controller';
|
||||
import { OutputGrpcClientService } from './outputs.service';
|
||||
import { OutputsService } from './outputs.service';
|
||||
|
||||
describe('OutputsController', () => {
|
||||
let controller: OutputsController;
|
||||
@@ -8,7 +8,7 @@ describe('OutputsController', () => {
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [OutputsController],
|
||||
providers: [OutputGrpcClientService],
|
||||
providers: [OutputsService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<OutputsController>(OutputsController);
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
import { Controller, Delete, Get, OnModuleInit, Param, Post, Put } from '@nestjs/common';
|
||||
import { Client, ClientGrpc, MessagePattern, Payload } from '@nestjs/microservices';
|
||||
import { OutputGrpcClientService } from './outputs.service';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
MessagePattern,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { OutputsService } from './outputs.service';
|
||||
import { CreateOutputDto } from './dto/create-output.dto';
|
||||
import { UpdateOutputDto } from './dto/update-output.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { GrpcClientConfiguration } from './config/grpc-client';
|
||||
|
||||
@Controller('output')
|
||||
export class OutputsController implements OnModuleInit{
|
||||
|
||||
export class OutputsController implements OnModuleInit {
|
||||
@Client(GrpcClientConfiguration)
|
||||
private outputServiceClient: ClientGrpc;
|
||||
|
||||
private outputService: OutputGrpcClientService;
|
||||
private outputService: OutputsService;
|
||||
|
||||
onModuleInit() {
|
||||
this.outputService =
|
||||
this.outputServiceClient.getService<OutputGrpcClientService>('OutputService');
|
||||
this.outputServiceClient.getService<OutputsService>('OutputService');
|
||||
}
|
||||
@Post()
|
||||
create(@Payload() createOutputDto: CreateOutputDto) {
|
||||
@@ -34,7 +46,7 @@ export class OutputsController implements OnModuleInit{
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
update(@Param() id:string,@Payload() updateOutputDto: UpdateOutputDto) {
|
||||
update(@Param() id: string, @Payload() updateOutputDto: UpdateOutputDto) {
|
||||
return this.outputService.update(id, updateOutputDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { OutputGrpcClientService } from './outputs.service';
|
||||
import { OutputsService } from './outputs.service';
|
||||
import { OutputsController } from './outputs.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [OutputsController],
|
||||
providers: [OutputGrpcClientService]
|
||||
providers: [OutputsService],
|
||||
})
|
||||
export class OutputsModule {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreateOutputDto } from './dto/create-output.dto';
|
||||
import { UpdateOutputDto } from './dto/update-output.dto';
|
||||
|
||||
@Injectable()
|
||||
export class OutputGrpcClientService {
|
||||
export class OutputsService {
|
||||
create(createOutputDto: CreateOutputDto) {
|
||||
return 'This action adds a new output';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { PipelinesController } from './pipelines.controller';
|
||||
import { PipelineGrpcClientService } from './pipelines.service';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
|
||||
describe('PipelinesController', () => {
|
||||
let controller: PipelinesController;
|
||||
@@ -8,7 +8,7 @@ describe('PipelinesController', () => {
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [PipelinesController],
|
||||
providers: [PipelineGrpcClientService],
|
||||
providers: [PipelinesService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<PipelinesController>(PipelinesController);
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
import { Controller, Delete, Get, OnModuleInit, Param, Post, Put } from '@nestjs/common';
|
||||
import { Client, ClientGrpc, MessagePattern, Payload } from '@nestjs/microservices';
|
||||
import { PipelineGrpcClientService } from './pipelines.service';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
MessagePattern,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
import { CreatePipelineDto } from './dto/create-pipeline.dto';
|
||||
import { UpdatePipelineDto } from './dto/update-pipeline.dto';
|
||||
import { GrpcClientConfiguration } from './config/grpc-client';
|
||||
|
||||
@Controller('pipeline')
|
||||
export class PipelinesController implements OnModuleInit{
|
||||
|
||||
export class PipelinesController implements OnModuleInit {
|
||||
|
||||
@Client(GrpcClientConfiguration)
|
||||
private pipelineServiceClient: ClientGrpc;
|
||||
|
||||
private pipelineService: PipelineGrpcClientService;
|
||||
private pipelineService: PipelinesService;
|
||||
|
||||
onModuleInit() {
|
||||
this.pipelineService =
|
||||
this.pipelineServiceClient.getService<PipelineGrpcClientService>('PipelineService');
|
||||
this.pipelineServiceClient.getService<PipelinesService>(
|
||||
'PipelineService',
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@@ -34,21 +50,21 @@ export class PipelinesController implements OnModuleInit{
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
update(@Param() id:string,@Payload() updatePipelineDto: UpdatePipelineDto) {
|
||||
update(@Param() id: string, @Payload() updatePipelineDto: UpdatePipelineDto) {
|
||||
return this.pipelineService.update(id, updatePipelineDto);
|
||||
}
|
||||
|
||||
@Delete()
|
||||
remove(@Param() id:string) {
|
||||
remove(@Param() id: string) {
|
||||
return this.pipelineService.remove(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
getPipelineLogsMessages(@Param() id:string,@Payload() details:string){
|
||||
return this.pipelineService.getPipelineLogsMessages(id,details);
|
||||
getPipelineLogsMessages(@Param() id: string, @Payload() details: string) {
|
||||
return this.pipelineService.getPipelineLogsMessages(id, details);
|
||||
}
|
||||
|
||||
getPipelineStatus(id:string){
|
||||
return this.pipelineService.getPipelineStatus(id)
|
||||
getPipelineStatus(id: string) {
|
||||
return this.pipelineService.getPipelineStatus(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PipelineGrpcClientService } from './pipelines.service';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
import { PipelinesController } from './pipelines.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [PipelinesController],
|
||||
providers: [PipelineGrpcClientService]
|
||||
providers: [PipelinesService],
|
||||
})
|
||||
export class PipelinesModule {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreatePipelineDto } from './dto/create-pipeline.dto';
|
||||
import { UpdatePipelineDto } from './dto/update-pipeline.dto';
|
||||
|
||||
@Injectable()
|
||||
export class PipelineGrpcClientService {
|
||||
export class PipelinesService {
|
||||
create(createPipelineDto: CreatePipelineDto) {
|
||||
return 'This action adds a new pipeline';
|
||||
}
|
||||
@@ -24,11 +24,11 @@ export class PipelineGrpcClientService {
|
||||
return `This action removes a #${id} pipeline`;
|
||||
}
|
||||
|
||||
getPipelineLogsMessages(id:string,details:string){
|
||||
getPipelineLogsMessages(id: string, details: string) {
|
||||
return `This action perfoms a getLogMessages on #${id} pipeline`;
|
||||
}
|
||||
|
||||
getPipelineStatus(id:string){
|
||||
getPipelineStatus(id: string) {
|
||||
return `This action performs a getStatus on #${id} pipeline`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TransformationsController } from './transformations.controller';
|
||||
import { TransformationGrpcClientService } from './transformations.service';
|
||||
import { TransformationsService } from './transformations.service';
|
||||
|
||||
describe('TransformationsController', () => {
|
||||
let controller: TransformationsController;
|
||||
@@ -8,10 +8,12 @@ describe('TransformationsController', () => {
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [TransformationsController],
|
||||
providers: [TransformationGrpcClientService],
|
||||
providers: [TransformationsService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<TransformationsController>(TransformationsController);
|
||||
controller = module.get<TransformationsController>(
|
||||
TransformationsController,
|
||||
);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
import { Controller, Delete, Get, OnModuleInit, Param, Post, Put } from '@nestjs/common';
|
||||
import { Client, ClientGrpc, MessagePattern, Payload } from '@nestjs/microservices';
|
||||
import { TransformationGrpcClientService } from './transformations.service';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
MessagePattern,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { TransformationsService } from './transformations.service';
|
||||
import { CreateTransformationDto } from './dto/create-transformation.dto';
|
||||
import { UpdateTransformationDto } from './dto/update-transformation.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
@@ -8,21 +21,23 @@ import { GrpcClientConfiguration } from './config/grpc-client';
|
||||
|
||||
@Controller('transformation')
|
||||
export class TransformationsController implements OnModuleInit {
|
||||
|
||||
@Client(GrpcClientConfiguration)
|
||||
private transformationServiceClient: ClientGrpc;
|
||||
|
||||
private transformationService: TransformationGrpcClientService;
|
||||
private transformationService: TransformationsService;
|
||||
|
||||
onModuleInit() {
|
||||
this.transformationService =
|
||||
this.transformationServiceClient.getService<TransformationGrpcClientService>('TransformationService');
|
||||
this.transformationServiceClient.getService<TransformationsService>(
|
||||
'TransformationService',
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Payload() createTransformationDto: CreateTransformationDto[]) {
|
||||
|
||||
return createTransformationDto.map( transf => this.transformationService.create(transf))
|
||||
return createTransformationDto.map((transf) =>
|
||||
this.transformationService.create(transf),
|
||||
);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@@ -36,7 +51,10 @@ export class TransformationsController implements OnModuleInit {
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
update(@Param() id:string,@Payload() updateTransformationDto: UpdateTransformationDto) {
|
||||
update(
|
||||
@Param() id: string,
|
||||
@Payload() updateTransformationDto: UpdateTransformationDto,
|
||||
) {
|
||||
return this.transformationService.update(id, updateTransformationDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TransformationGrpcClientService } from './transformations.service';
|
||||
import { TransformationsService } from './transformations.service';
|
||||
import { TransformationsController } from './transformations.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [TransformationsController],
|
||||
providers: [TransformationGrpcClientService]
|
||||
providers: [TransformationsService],
|
||||
})
|
||||
export class TransformationsModule {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreateTransformationDto } from './dto/create-transformation.dto';
|
||||
import { UpdateTransformationDto } from './dto/update-transformation.dto';
|
||||
|
||||
@Injectable()
|
||||
export class TransformationGrpcClientService {
|
||||
export class TransformationsService {
|
||||
create(createTransformationDto: CreateTransformationDto) {
|
||||
return 'This action adds a new transformation';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user