Feature/59 add tracks to log form (#70)

* adding tracks

* adding tracks

* adding tracks
This commit was merged in pull request #70.
This commit is contained in:
2025-03-22 09:28:10 -05:00
committed by GitHub
parent 70fde43801
commit 08498a64d8
27 changed files with 819 additions and 303 deletions

View File

@@ -7,6 +7,8 @@ import {
Param,
Post,
Put,
Query,
UploadedFile,
UseGuards,
UseInterceptors
} from '@nestjs/common';
@@ -16,12 +18,16 @@ import { LogService } from './log.service';
import { CustomError } from '../error/customError';
import { AuthGuard } from '@noahspan/noahspan-modules';
import { LogInterceptor } from './interceptors/log.interceptor';
import { FileService } from '../file/file.service';
import { FileInterceptor } from '@nestjs/platform-express';
@Controller('logs')
@UseInterceptors(new LogInterceptor())
export class LogController {
constructor(private readonly logService: LogService) {}
constructor(
private readonly fileService: FileService,
private readonly logService: LogService
) {}
@Get(':partitionKey/:rowKey')
async find(
@@ -98,4 +104,35 @@ export class LogController {
throw new HttpException(customError.message, customError.statusCode);
}
}
@UseGuards(AuthGuard)
@Post(':partitionKey/:rowKey/track')
@UseInterceptors(FileInterceptor('file'))
async createTrack(@Param('rowKey') rowKey: string, @UploadedFile() file: Express.Multer.File) {
try {
const containerName = 'tracks';
const url = await this.fileService.uploadFile(file, containerName, rowKey);
return { url }
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
@UseGuards(AuthGuard)
@Delete(':partitionKey/:rowKey/track')
async deleteTrack(@Param('rowKey') rowKey: string, @Query('fileName') fileName: string): Promise<void> {
try {
console.log(fileName)
const containerName = 'tracks';
return await this.fileService.deleteFile(containerName, rowKey, fileName)
} catch (error) {
const customError = error as CustomError;
throw new HttpException(customError.message, customError.statusCode);
}
}
}