mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-20 22:49:08 +00:00
Fix and add upload file
This commit is contained in:
@@ -11,19 +11,15 @@ import {
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import {
|
||||
ApiBasicAuth,
|
||||
ApiBearerAuth,
|
||||
ApiConsumes,
|
||||
ApiOAuth2,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiBearerAuth, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
||||
import { ConnectorClientService } from 'src/clients/connector/client.service';
|
||||
import { AddTagDto } from './dtos/add-tag';
|
||||
import { CreateConnectorDto } from './dtos/create-connector';
|
||||
import { DeleteConnectorDto } from './dtos/delete-connector';
|
||||
import { GetAllDto } from './dtos/get-all';
|
||||
import { RemoveTagDto } from './dtos/remove-tag';
|
||||
import { UpdateDto } from './dtos/update';
|
||||
import { UploadFileDto } from './dtos/upload-file';
|
||||
|
||||
@ApiTags('connectors')
|
||||
@ApiBearerAuth()
|
||||
@@ -31,7 +27,7 @@ import { UpdateDto } from './dtos/update';
|
||||
export class ConnectorController {
|
||||
constructor(private connectorClientService: ConnectorClientService) {}
|
||||
|
||||
@Post('/')
|
||||
@Post()
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
async uploadConnector(
|
||||
@@ -42,10 +38,22 @@ export class ConnectorController {
|
||||
|
||||
const response = await this.connectorClientService.uploadConnector({
|
||||
file,
|
||||
connector: body,
|
||||
connector: JSON.parse(body.connector),
|
||||
});
|
||||
|
||||
console.log('X', response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post('/upload')
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
async uploadFile(@UploadedFile() file, @Body() { name }: UploadFileDto) {
|
||||
console.log(`/upload`, 'Upload Connector Route');
|
||||
|
||||
const response = await this.connectorClientService.uploadFile({
|
||||
file,
|
||||
name,
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -171,11 +179,15 @@ export class ConnectorController {
|
||||
}
|
||||
|
||||
@Delete('/:plugin')
|
||||
async deleteConnector(@Param('plugin') plugin: string) {
|
||||
async deleteConnector(
|
||||
@Param('plugin') plugin: string,
|
||||
@Body() { version }: DeleteConnectorDto,
|
||||
) {
|
||||
console.log(`/upload`, 'Upload Connector Route');
|
||||
|
||||
const response: any = await this.connectorClientService.deleteConnector(
|
||||
plugin,
|
||||
version,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,33 +5,5 @@ export class CreateConnectorDto {
|
||||
file: string;
|
||||
|
||||
@ApiProperty()
|
||||
category: string;
|
||||
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
|
||||
@ApiProperty()
|
||||
image: string;
|
||||
|
||||
@ApiProperty()
|
||||
docs: string;
|
||||
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'skip_select_entities: boolean skip_select_columns: boolean;',
|
||||
})
|
||||
options: {
|
||||
skip_select_entities: boolean;
|
||||
skip_select_columns: boolean;
|
||||
};
|
||||
|
||||
@ApiProperty({
|
||||
type: 'array',
|
||||
items: {
|
||||
properties: {},
|
||||
},
|
||||
})
|
||||
connection_controls: object[];
|
||||
connector: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class DeleteConnectorDto {
|
||||
@ApiProperty()
|
||||
version: string;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class UploadFileDto {
|
||||
@ApiProperty({ format: 'binary' })
|
||||
file: string;
|
||||
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
}
|
||||
Reference in New Issue
Block a user