implementation of rest comunication on gateway

This commit is contained in:
rodrigo.zamboni
2022-01-25 14:46:23 -03:00
parent 9dbe3ec33b
commit 332e0f0d80
66 changed files with 5450 additions and 4039 deletions
@@ -0,0 +1,6 @@
export class CreateRestEnrichmentDto {
type:string;
columns:string[]
}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestEnrichmentDto } from './create-rest-enrichment.dto';
export class UpdateRestEnrichmentDto extends PartialType(CreateRestEnrichmentDto) {}
@@ -0,0 +1,7 @@
export class RestEnrichment {
id:string;
type:string;
columns:string[]
}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestEnrichmentsController } from './rest-enrichments.controller';
import { RestEnrichmentsService } from './rest-enrichments.service';
describe('RestEnrichmentsController', () => {
let controller: RestEnrichmentsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestEnrichmentsController],
providers: [RestEnrichmentsService],
}).compile();
controller = module.get<RestEnrichmentsController>(RestEnrichmentsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,105 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Put } from '@nestjs/common';
import { RestEnrichmentsService } from './rest-enrichments.service';
import { CreateRestEnrichmentDto } from './dto/create-rest-enrichment.dto';
import { UpdateRestEnrichmentDto } from './dto/update-rest-enrichment.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('enrichment')
export class RestEnrichmentsController {
constructor(private readonly restEnrichmentsService: RestEnrichmentsService) {}
@Post()
async create(@Body() body: CreateRestEnrichmentDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/enrichment`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/enrichment`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id')
async show(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/enrichment/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(@Param('id') id: string, @Body() body: UpdateRestEnrichmentDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/enrichment/${id}`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Delete(':id')
async remove(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/enrichment/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestEnrichmentsService } from './rest-enrichments.service';
import { RestEnrichmentsController } from './rest-enrichments.controller';
@Module({
controllers: [RestEnrichmentsController],
providers: [RestEnrichmentsService]
})
export class RestEnrichmentsModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestEnrichmentsService } from './rest-enrichments.service';
describe('RestEnrichmentsService', () => {
let service: RestEnrichmentsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestEnrichmentsService],
}).compile();
service = module.get<RestEnrichmentsService>(RestEnrichmentsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestEnrichmentDto } from './dto/create-rest-enrichment.dto';
import { UpdateRestEnrichmentDto } from './dto/update-rest-enrichment.dto';
@Injectable()
export class RestEnrichmentsService {
create(createRestEnrichmentDto: CreateRestEnrichmentDto) {
return 'This action adds a new restEnrichment';
}
findAll() {
return `This action returns all restEnrichments`;
}
findOne(id: number) {
return `This action returns a #${id} restEnrichment`;
}
update(id: number, updateRestEnrichmentDto: UpdateRestEnrichmentDto) {
return `This action updates a #${id} restEnrichment`;
}
remove(id: number) {
return `This action removes a #${id} restEnrichment`;
}
}
@@ -0,0 +1 @@
export class CreateRestFactoryDto {}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestFactoryDto } from './create-rest-factory.dto';
export class UpdateRestFactoryDto extends PartialType(CreateRestFactoryDto) {}
@@ -0,0 +1 @@
export class RestFactory {}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestFactoryController } from './rest-factory.controller';
import { RestFactoryService } from './rest-factory.service';
describe('RestFactoryController', () => {
let controller: RestFactoryController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestFactoryController],
providers: [RestFactoryService],
}).compile();
controller = module.get<RestFactoryController>(RestFactoryController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,69 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { RestFactoryService } from './rest-factory.service';
import { CreateRestFactoryDto } from './dto/create-rest-factory.dto';
import { UpdateRestFactoryDto } from './dto/update-rest-factory.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('factory')
export class RestFactoryController {
constructor(private readonly restFactoryService: RestFactoryService) {}
@Get('/start')
async startDagFactory() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/factory/start`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get('/pipeline_params')
async sendJSONSettingsToDagFactory() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/factory/pipeline_params`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get('/start/:pipelineId')
async startDag(@Param('pipelineId') pipelineId:string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/factory/start/${pipelineId}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestFactoryService } from './rest-factory.service';
import { RestFactoryController } from './rest-factory.controller';
@Module({
controllers: [RestFactoryController],
providers: [RestFactoryService]
})
export class RestFactoryModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestFactoryService } from './rest-factory.service';
describe('RestFactoryService', () => {
let service: RestFactoryService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestFactoryService],
}).compile();
service = module.get<RestFactoryService>(RestFactoryService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestFactoryDto } from './dto/create-rest-factory.dto';
import { UpdateRestFactoryDto } from './dto/update-rest-factory.dto';
@Injectable()
export class RestFactoryService {
create(createRestFactoryDto: CreateRestFactoryDto) {
return 'This action adds a new restFactory';
}
findAll() {
return `This action returns all restFactory`;
}
findOne(id: number) {
return `This action returns a #${id} restFactory`;
}
update(id: number, updateRestFactoryDto: UpdateRestFactoryDto) {
return `This action updates a #${id} restFactory`;
}
remove(id: number) {
return `This action removes a #${id} restFactory`;
}
}
@@ -0,0 +1,22 @@
import { ApiProperty } from "@nestjs/swagger";
export class CreateRestInputDto {
@ApiProperty()
cron:string;
@ApiProperty({
description:"Name of the input",
example:"Test Name"
})
name:string;
@ApiProperty()
plugin:string;
@ApiProperty()
values:string;
@ApiProperty()
operation:string;
}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestInputDto } from './create-rest-input.dto';
export class UpdateRestInputDto extends PartialType(CreateRestInputDto) {}
@@ -0,0 +1,14 @@
export class RestInput {
id:string;
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestInputsController } from './rest-inputs.controller';
import { RestInputsService } from './rest-inputs.service';
describe('RestInputsController', () => {
let controller: RestInputsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestInputsController],
providers: [RestInputsService],
}).compile();
controller = module.get<RestInputsController>(RestInputsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,134 @@
import axios from 'axios';
require("dotenv").config();
import { RestInputsService } from './rest-inputs.service';
import { CreateInputGrpcClientDto } from 'src/inputs/dto/create-input-grpc-client.dto';
import { UpdateInputGrpcClientDto } from 'src/inputs/dto/update-input-grpc-client.dto';
import { Controller, Get, Post, Body, Patch, Param, Delete, Put, Headers } from '@nestjs/common';
import { AuthenticateController } from 'src/utils/Authenticate';
@Controller('input')
export class RestInputsController {
constructor(private readonly restInputsService: RestInputsService) {}
@Post('/test-connection/')
async testConnection(@Body() body){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/input/test-connection`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Post()
async create(@Body() body: CreateInputGrpcClientDto){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/input`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list(){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/input`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get('/:id')
async show(@Param() id: string){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/input/:${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(
@Body() body: UpdateInputGrpcClientDto,
@Param() id: string,
){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/input/:${id}`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Delete(':id')
async delete(@Param() id: string){
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/input/:${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestInputsService } from './rest-inputs.service';
import { RestInputsController } from './rest-inputs.controller';
@Module({
controllers: [RestInputsController],
providers: [RestInputsService]
})
export class RestInputsModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestInputsService } from './rest-inputs.service';
describe('RestInputsService', () => {
let service: RestInputsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestInputsService],
}).compile();
service = module.get<RestInputsService>(RestInputsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestInputDto } from './dto/create-rest-input.dto';
import { UpdateRestInputDto } from './dto/update-rest-input.dto';
@Injectable()
export class RestInputsService {
create(createRestInputDto: CreateRestInputDto) {
return 'This action adds a new restInput';
}
findAll() {
return `This action returns all restInputs`;
}
findOne(id: number) {
return `This action returns a #${id} restInput`;
}
update(id: number, updateRestInputDto: UpdateRestInputDto) {
return `This action updates a #${id} restInput`;
}
remove(id: number) {
return `This action removes a #${id} restInput`;
}
}
@@ -0,0 +1,7 @@
export class CreateRestOutputDto {
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestOutputDto } from './create-rest-output.dto';
export class UpdateRestOutputDto extends PartialType(CreateRestOutputDto) {}
@@ -0,0 +1 @@
export class RestOutput {}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestOutputsController } from './rest-outputs.controller';
import { RestOutputsService } from './rest-outputs.service';
describe('RestOutputsController', () => {
let controller: RestOutputsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestOutputsController],
providers: [RestOutputsService],
}).compile();
controller = module.get<RestOutputsController>(RestOutputsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,103 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Put } from '@nestjs/common';
import { RestOutputsService } from './rest-outputs.service';
import { CreateRestOutputDto } from './dto/create-rest-output.dto';
import { UpdateRestOutputDto } from './dto/update-rest-output.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('output')
export class RestOutputsController {
constructor(private readonly restOutputsService: RestOutputsService) {}
@Post()
async create(@Body() body: CreateRestOutputDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/output`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/output`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id')
async show(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/output/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(@Param('id') id: string, @Body() body: UpdateRestOutputDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/output/${id}`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Delete(':id')
async remove(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/output/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestOutputsService } from './rest-outputs.service';
import { RestOutputsController } from './rest-outputs.controller';
@Module({
controllers: [RestOutputsController],
providers: [RestOutputsService]
})
export class RestOutputsModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestOutputsService } from './rest-outputs.service';
describe('RestOutputsService', () => {
let service: RestOutputsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestOutputsService],
}).compile();
service = module.get<RestOutputsService>(RestOutputsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestOutputDto } from './dto/create-rest-output.dto';
import { UpdateRestOutputDto } from './dto/update-rest-output.dto';
@Injectable()
export class RestOutputsService {
create(createRestOutputDto: CreateRestOutputDto) {
return 'This action adds a new restOutput';
}
findAll() {
return `This action returns all restOutputs`;
}
findOne(id: number) {
return `This action returns a #${id} restOutput`;
}
update(id: number, updateRestOutputDto: UpdateRestOutputDto) {
return `This action updates a #${id} restOutput`;
}
remove(id: number) {
return `This action removes a #${id} restOutput`;
}
}
@@ -0,0 +1 @@
export class CreateRestPipelineDto {}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestPipelineDto } from './create-rest-pipeline.dto';
export class UpdateRestPipelineDto extends PartialType(CreateRestPipelineDto) {}
@@ -0,0 +1 @@
export class RestPipeline {}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestPipelinesController } from './rest-pipelines.controller';
import { RestPipelinesService } from './rest-pipelines.service';
describe('RestPipelinesController', () => {
let controller: RestPipelinesController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestPipelinesController],
providers: [RestPipelinesService],
}).compile();
controller = module.get<RestPipelinesController>(RestPipelinesController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,140 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Put } from '@nestjs/common';
import { RestPipelinesService } from './rest-pipelines.service';
import { CreateRestPipelineDto } from './dto/create-rest-pipeline.dto';
import { UpdateRestPipelineDto } from './dto/update-rest-pipeline.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('pipeline')
export class RestPipelinesController {
constructor(private readonly restPipelinesService: RestPipelinesService) {}
@Post()
async create(@Body() body: CreateRestPipelineDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/pipeline`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/pipeline`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id/logs/details')
async showLogs(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/pipeline/${id}/logs/details`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id/status')
async showStatus(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/pipeline/${id}/status`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id')
async show(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/pipeline/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(@Param('id') id: string, @Body() body: UpdateRestPipelineDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/pipeline/${id}`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Delete(':id')
async remove(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/pipeline/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestPipelinesService } from './rest-pipelines.service';
import { RestPipelinesController } from './rest-pipelines.controller';
@Module({
controllers: [RestPipelinesController],
providers: [RestPipelinesService]
})
export class RestPipelinesModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestPipelinesService } from './rest-pipelines.service';
describe('RestPipelinesService', () => {
let service: RestPipelinesService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestPipelinesService],
}).compile();
service = module.get<RestPipelinesService>(RestPipelinesService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestPipelineDto } from './dto/create-rest-pipeline.dto';
import { UpdateRestPipelineDto } from './dto/update-rest-pipeline.dto';
@Injectable()
export class RestPipelinesService {
create(createRestPipelineDto: CreateRestPipelineDto) {
return 'This action adds a new restPipeline';
}
findAll() {
return `This action returns all restPipelines`;
}
findOne(id: number) {
return `This action returns a #${id} restPipeline`;
}
update(id: number, updateRestPipelineDto: UpdateRestPipelineDto) {
return `This action updates a #${id} restPipeline`;
}
remove(id: number) {
return `This action removes a #${id} restPipeline`;
}
}
@@ -0,0 +1 @@
export class CreateRestTransformationDto {}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestTransformationDto } from './create-rest-transformation.dto';
export class UpdateRestTransformationDto extends PartialType(CreateRestTransformationDto) {}
@@ -0,0 +1 @@
export class RestTransformation {}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestTransformationsController } from './rest-transformations.controller';
import { RestTransformationsService } from './rest-transformations.service';
describe('RestTransformationsController', () => {
let controller: RestTransformationsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestTransformationsController],
providers: [RestTransformationsService],
}).compile();
controller = module.get<RestTransformationsController>(RestTransformationsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,110 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Put } from '@nestjs/common';
import { RestTransformationsService } from './rest-transformations.service';
import { CreateRestTransformationDto } from './dto/create-rest-transformation.dto';
import { UpdateRestTransformationDto } from './dto/update-rest-transformation.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('transformation')
export class RestTransformationsController {
constructor(private readonly restTransformationsService: RestTransformationsService) {}
@Post()
async create(@Body() body: CreateRestTransformationDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/transformation`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list() {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/transformation`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Get(':id')
async show(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/transformation/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(@Param('id') id: string, @Body() body: UpdateRestTransformationDto) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/transformation/${id}`,
body,
{
headers:{
"Authorization":`Token ${accessToken}`,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Delete(':id')
async remove(@Param('id') id: string) {
const authController = new AuthenticateController()
const accessToken = await authController.authenticate()
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/transformation/${id}`,
{
headers:{
"Authorization":`Token ${accessToken}`
}
}
)
return connectionResponse.data
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestTransformationsService } from './rest-transformations.service';
import { RestTransformationsController } from './rest-transformations.controller';
@Module({
controllers: [RestTransformationsController],
providers: [RestTransformationsService]
})
export class RestTransformationsModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestTransformationsService } from './rest-transformations.service';
describe('RestTransformationsService', () => {
let service: RestTransformationsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestTransformationsService],
}).compile();
service = module.get<RestTransformationsService>(RestTransformationsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestTransformationDto } from './dto/create-rest-transformation.dto';
import { UpdateRestTransformationDto } from './dto/update-rest-transformation.dto';
@Injectable()
export class RestTransformationsService {
create(createRestTransformationDto: CreateRestTransformationDto) {
return 'This action adds a new restTransformation';
}
findAll() {
return `This action returns all restTransformations`;
}
findOne(id: number) {
return `This action returns a #${id} restTransformation`;
}
update(id: number, updateRestTransformationDto: UpdateRestTransformationDto) {
return `This action updates a #${id} restTransformation`;
}
remove(id: number) {
return `This action removes a #${id} restTransformation`;
}
}
@@ -0,0 +1 @@
export class CreateRestUserDto {}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestUserDto } from './create-rest-user.dto';
export class UpdateRestUserDto extends PartialType(CreateRestUserDto) {}
@@ -0,0 +1 @@
export class RestUser {}
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestUserController } from './rest-user.controller';
import { RestUserService } from './rest-user.service';
describe('RestUserController', () => {
let controller: RestUserController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestUserController],
providers: [RestUserService],
}).compile();
controller = module.get<RestUserController>(RestUserController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -0,0 +1,81 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { RestUserService } from './rest-user.service';
import { CreateRestUserDto } from './dto/create-rest-user.dto';
import { UpdateRestUserDto } from './dto/update-rest-user.dto';
import { AuthenticateController } from 'src/utils/Authenticate';
import axios from 'axios';
@Controller('user')
export class RestUserController {
constructor(private readonly restUserService: RestUserService) {}
@Post('/register')
async create(@Body() body: CreateRestUserDto) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/register`,
body,
{
headers:{
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Post('/auth')
async auth(@Body() body: {username:string, password:string}) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/auth`,
body,
{
headers:{
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Post('/confirm')
async confirm(@Body() body: {username:string, confirmationCode:string}) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/confirm`,
body,
{
headers:{
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Post('/resendCode')
async resendCode(@Body() body: {username:string}) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/user/resendCode`,
body,
{
headers:{
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
}
+9
View File
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RestUserService } from './rest-user.service';
import { RestUserController } from './rest-user.controller';
@Module({
controllers: [RestUserController],
providers: [RestUserService]
})
export class RestUserModule {}
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestUserService } from './rest-user.service';
describe('RestUserService', () => {
let service: RestUserService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestUserService],
}).compile();
service = module.get<RestUserService>(RestUserService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
+26
View File
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateRestUserDto } from './dto/create-rest-user.dto';
import { UpdateRestUserDto } from './dto/update-rest-user.dto';
@Injectable()
export class RestUserService {
create(createRestUserDto: CreateRestUserDto) {
return 'This action adds a new restUser';
}
findAll() {
return `This action returns all restUser`;
}
findOne(id: number) {
return `This action returns a #${id} restUser`;
}
update(id: number, updateRestUserDto: UpdateRestUserDto) {
return `This action updates a #${id} restUser`;
}
remove(id: number) {
return `This action removes a #${id} restUser`;
}
}