Skip to content

Commit

Permalink
Fix: 문제 업로드 시 발생하는 버그 수정
Browse files Browse the repository at this point in the history
- file type validaton 수정

Related to #18
  • Loading branch information
Zamoca42 committed Feb 11, 2024
1 parent 432f6a8 commit 9c9f832
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
6 changes: 1 addition & 5 deletions backend/src/toeic/toeic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export class ToeicService {
}

async findAll() {
return this.prisma.toeic.findMany({
where: {
is_public: true,
},
});
return this.prisma.toeic.findMany();
}

async findOne(id: number) {
Expand Down
8 changes: 1 addition & 7 deletions backend/src/upload/pipe/workbook.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
ConflictException,
Injectable,
ParseFilePipe,
PipeTransform,
} from '@nestjs/common';
import { ConflictException, Injectable, PipeTransform } from '@nestjs/common';
import { readFile } from 'xlsx';
import { UploadService } from '../upload.service';
import { QuestionInFile } from '../upload.interface';
Expand All @@ -16,7 +11,6 @@ import { QuestionInFile } from '../upload.interface';
*/
@Injectable()
export class ParseWorkbookPipe
extends ParseFilePipe
implements PipeTransform<Express.Multer.File, Promise<QuestionInFile>>
{
private readonly uploadService = new UploadService();
Expand Down
4 changes: 3 additions & 1 deletion backend/src/upload/upload.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Controller,
FileTypeValidator,
ParseFilePipe,
Post,
UploadedFile,
UseGuards,
Expand Down Expand Up @@ -31,9 +32,10 @@ export class UploadController {
@ApiFile()
async handleXlsxFile(
@UploadedFile(
new ParseWorkbookPipe({
new ParseFilePipe({
validators: [new FileTypeValidator({ fileType: 'sheet' })],
}),
new ParseWorkbookPipe(),
)
file: QuestionInFile,
) {
Expand Down

0 comments on commit 9c9f832

Please sign in to comment.