mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-08 14:39:09 +00:00
FIX: Create VPN using multipart form data to fetch file
This commit is contained in:
@@ -9,10 +9,12 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
UploadedFile,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiConsumes, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import {
|
||||
CreateNetworkConfigReq,
|
||||
@@ -22,6 +24,7 @@ import {
|
||||
UpdateNetworkConfigReq,
|
||||
UpdateNetworkConfigRes,
|
||||
} from './dto/network-config';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
|
||||
@ApiTags('Network Config')
|
||||
@Controller('network-config')
|
||||
@@ -87,15 +90,18 @@ export class NetworkConfigController {
|
||||
|
||||
@Post()
|
||||
@ApiOkResponse({ type: CreateNetworkConfigRes })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(FileInterceptor('OVPN_FILE'))
|
||||
async createNetworkConfigs(
|
||||
@User() user: RequestUser,
|
||||
@Body() body: CreateNetworkConfigReq,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
) {
|
||||
this.logger.info('POST /network-config', {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
return this.networkConfigService.createNetworkConfig(body, {
|
||||
return this.networkConfigService.createNetworkConfig(body, file, {
|
||||
customer_name: user.customer_name,
|
||||
customer_id: user.customer_id,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user