mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-15 16:19:07 +00:00
implementation of rest comunication on gateway
This commit is contained in:
+3
-1
@@ -32,4 +32,6 @@ lerna-debug.log*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
.env
|
||||
@@ -29,6 +29,8 @@
|
||||
"@nestjs/microservices": "^8.2.4",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/swagger": "^5.1.5",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"grpc": "^1.24.11",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
|
||||
+13
-2
@@ -5,11 +5,22 @@ import { OutputsModule } from './outputs/outputs.module';
|
||||
import { EnrichmentModule } from './enrichment/enrichment.module';
|
||||
import { TransformationsModule } from './transformations/transformations.module';
|
||||
import { PipelinesModule } from './pipelines/pipelines.module';
|
||||
import { RestInputsModule } from './rest/rest-inputs/rest-inputs.module';
|
||||
import { RestOutputsModule } from './rest/rest-outputs/rest-outputs.module';
|
||||
import { RestEnrichmentsModule } from './rest/rest-enrichments/rest-enrichments.module';
|
||||
import { RestTransformationsModule } from './rest/rest-transformations/rest-transformations.module';
|
||||
import { RestPipelinesModule } from './rest/rest-pipelines/rest-pipelines.module';
|
||||
import { RestUserModule } from './rest/rest-user/rest-user.module';
|
||||
import { RestFactoryModule } from './rest/rest-factory/rest-factory.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
InputGrpcClientModule,
|
||||
OutputsModule, EnrichmentModule, TransformationsModule, PipelinesModule
|
||||
RestInputsModule, RestOutputsModule, RestEnrichmentsModule, RestTransformationsModule, RestPipelinesModule, RestUserModule, RestFactoryModule,
|
||||
// InputGrpcClientModule,
|
||||
//OutputsModule,
|
||||
//EnrichmentModule,
|
||||
//TransformationsModule,
|
||||
//PipelinesModule
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
|
||||
@@ -15,8 +15,8 @@ import { GrpcClientConfiguration } from './config/grpc-client';
|
||||
import { TestConnectionDTO } from './dto/test-connection-grpc-client.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('inputs')
|
||||
@Controller('input')
|
||||
@ApiTags('inputs-grpc')
|
||||
@Controller('grpc/input')
|
||||
export class InputGrpcClientController implements OnModuleInit {
|
||||
@Client(GrpcClientConfiguration)
|
||||
private inputServiceClient: ClientGrpc;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { InputGrpcClientService } from './input-grpc-client.service';
|
||||
import { InputGrpcClientController } from './input-grpc-client.controller';
|
||||
// import { InputRestClientController } from './input-rest-client.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [InputGrpcClientController],
|
||||
controllers: [
|
||||
InputGrpcClientController,
|
||||
// InputRestClientController
|
||||
],
|
||||
providers: [InputGrpcClientService],
|
||||
})
|
||||
export class InputGrpcClientModule {}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put, Redirect } from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import axios from 'axios';
|
||||
import { Console } from 'console';
|
||||
import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
|
||||
@Controller('input')
|
||||
export class InputRestClientController {
|
||||
|
||||
|
||||
@Get('/test-connection/')
|
||||
async testConnection(){
|
||||
console.log(process.env.DEV_URL+`/test-connection`, "ON TEST CONNECTION ROUTE")
|
||||
await axios.get(process.env.DEV_URL+`/test-connection`).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createInputDto: CreateInputGrpcClientDto){
|
||||
console.log(createInputDto)
|
||||
console.log(process.env.DEV_URL+`/input`, "ON CREATE ROUTE")
|
||||
|
||||
await axios.post(process.env.DEV_URL+'/input',createInputDto).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
@Get()
|
||||
async list(){
|
||||
console.log(process.env.DEV_URL+`/input`, "ON GET ROUTE")
|
||||
await axios.get(process.env.DEV_URL+`/input`).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@Get('/:id')
|
||||
async show(@Param() id: string){
|
||||
console.log(process.env.DEV_URL+`/input/${id}`, "ON SHOW ROUTE")
|
||||
await axios.get(process.env.DEV_URL+`/input/${id}`).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
@Param() id: string,
|
||||
){
|
||||
console.log(process.env.DEV_URL+`/input/${id}`, "ON UPDATE ROUTE")
|
||||
await axios.put(process.env.DEV_URL+`input/${id}`,updateInputDto).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() id: string){
|
||||
console.log(process.env.DEV_URL+`/input/${id}`, "ON DELETE ROUTE")
|
||||
|
||||
await axios.delete(process.env.DEV_URL+`/input/${id}`).then( (response) => {
|
||||
return response
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { AppModule } from './app.module';
|
||||
require("dotenv").config();
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import axios from "axios";
|
||||
|
||||
|
||||
export class AuthenticateController{
|
||||
|
||||
private username:string;
|
||||
private password:string;
|
||||
|
||||
constructor(){
|
||||
this.username = process.env.AUTH_USERNAME
|
||||
this.password = process.env.AUTH_PASSWORD
|
||||
}
|
||||
|
||||
|
||||
|
||||
async authenticate():Promise<string>{
|
||||
|
||||
const response = await axios.post(process.env.AUTH_ROUTE,
|
||||
{
|
||||
username:this.username,
|
||||
password:this.password
|
||||
}
|
||||
)
|
||||
|
||||
return response.data.accessToken
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user