From 748e59b34566bbf27a30c89bffa35f687a2e2c99 Mon Sep 17 00:00:00 2001 From: Jeongmin <138637345+yaongmeow@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:30:23 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"[feat]=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=9C=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EA=B4=80=EB=A6=AC=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=ED=95=98=EB=8A=94=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=83=9D=EC=84=B1"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/src/app.module.ts | 6 ++--- BE/src/app.service.ts | 5 ++-- BE/src/auth/auth.module.ts | 6 ++--- BE/src/file/file.module.ts | 8 ------ BE/src/file/file.service.ts | 36 --------------------------- BE/src/postings/postings.module.ts | 5 ++-- BE/src/postings/postings.service.ts | 5 ++-- BE/src/timelines/timelines.module.ts | 6 ++--- BE/src/timelines/timelines.service.ts | 5 ++-- BE/src/users/users.module.ts | 5 ++-- BE/src/users/users.service.ts | 5 ++-- 11 files changed, 18 insertions(+), 74 deletions(-) delete mode 100644 BE/src/file/file.module.ts delete mode 100644 BE/src/file/file.service.ts diff --git a/BE/src/app.module.ts b/BE/src/app.module.ts index fcb89d7..cc74bcf 100644 --- a/BE/src/app.module.ts +++ b/BE/src/app.module.ts @@ -7,8 +7,7 @@ import { TimelinesModule } from './timelines/timelines.module'; import { AuthModule } from './auth/auth.module'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { DatabaseModule } from './database/database.module'; -// import { StorageModule } from './storage/storage.module'; -import { FileModule } from './file/file.module'; +import { StorageModule } from './storage/storage.module'; import { JwtModule } from '@nestjs/jwt'; import { EmailModule } from './email/email.module'; @@ -23,8 +22,7 @@ import { EmailModule } from './email/email.module'; secret: process.env.JWT_SECRET_ACCESS, signOptions: { expiresIn: '30d' }, }), - // StorageModule, - FileModule, + StorageModule, UsersModule, PostingsModule, TimelinesModule, diff --git a/BE/src/app.service.ts b/BE/src/app.service.ts index 89787e8..477d7c5 100644 --- a/BE/src/app.service.ts +++ b/BE/src/app.service.ts @@ -1,10 +1,9 @@ -// import { StorageService } from './storage/storage.service'; -import { FileService } from './file/file.service'; +import { StorageService } from './storage/storage.service'; import { Injectable } from '@nestjs/common'; @Injectable() export class AppService { - constructor(private readonly storageService: FileService) {} + constructor(private readonly storageService: StorageService) {} getHello(): string { return ` diff --git a/BE/src/auth/auth.module.ts b/BE/src/auth/auth.module.ts index 69fd8cc..fe6a376 100644 --- a/BE/src/auth/auth.module.ts +++ b/BE/src/auth/auth.module.ts @@ -3,8 +3,7 @@ import { AuthService } from './auth.service'; import { AuthController } from './auth.controller'; import { UsersModule } from 'src/users/users.module'; import { UsersService } from 'src/users/users.service'; -// import { StorageService } from 'src/storage/storage.service'; -import { FileService } from 'src/file/file.service'; +import { StorageService } from 'src/storage/storage.service'; import { HttpModule } from '@nestjs/axios'; import { AuthGuard } from './auth.guard'; import { EmailModule } from 'src/email/email.module'; @@ -17,8 +16,7 @@ import { AppleLoginStrategy } from 'src/socialLogin/apple-login-strategy'; providers: [ AuthService, UsersService, - // StorageService, - FileService, + StorageService, AuthGuard, KakaoLoginStrategy, AppleLoginStrategy, diff --git a/BE/src/file/file.module.ts b/BE/src/file/file.module.ts deleted file mode 100644 index 496fb49..0000000 --- a/BE/src/file/file.module.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { FileService } from './file.service'; -import { Module } from '@nestjs/common'; - -@Module({ - providers: [FileService], - exports: [FileService], -}) -export class FileModule {} diff --git a/BE/src/file/file.service.ts b/BE/src/file/file.service.ts deleted file mode 100644 index d85ab9f..0000000 --- a/BE/src/file/file.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { mkdir, unlink, writeFile } from 'fs/promises'; -import { v4 as uuidv4 } from 'uuid'; - -@Injectable() -export class FileService { - private readonly basePath = 'static/'; - - constructor() {} - - private generateFilename(originalname: string) { - const extension = originalname.split('.').pop(); - const uniqueId = uuidv4(); - return `${uniqueId}.${extension}`; - } - - async upload(path: string, file: Express.Multer.File) { - const filePath = - this.basePath + path + this.generateFilename(file.originalname); - await mkdir(this.basePath + path, { recursive: true }); - await writeFile(filePath, file.buffer); - - return { - imageUrl: filePath, - path: filePath, - }; - } - - async getImageUrl(key: string): Promise { - return this.basePath + key; - } - - async delete(path: string) { - await unlink(this.basePath + path); - } -} diff --git a/BE/src/postings/postings.module.ts b/BE/src/postings/postings.module.ts index 62815a1..d03d59f 100644 --- a/BE/src/postings/postings.module.ts +++ b/BE/src/postings/postings.module.ts @@ -7,11 +7,10 @@ import { PostingsRepository } from './repositories/postings.repository'; import { LikedsRepository } from './repositories/likeds.repository'; import { ReportsRepository } from './repositories/reports.repository'; import { UsersModule } from '../users/users.module'; -// import { StorageModule } from 'src/storage/storage.module'; -import { FileModule } from 'src/file/file.module'; +import { StorageModule } from 'src/storage/storage.module'; @Module({ - imports: [DatabaseModule, UsersModule, FileModule], + imports: [DatabaseModule, UsersModule, StorageModule], controllers: [PostingsController], providers: [ ...postingsProviders, diff --git a/BE/src/postings/postings.service.ts b/BE/src/postings/postings.service.ts index 1ac86a7..f329d5b 100644 --- a/BE/src/postings/postings.service.ts +++ b/BE/src/postings/postings.service.ts @@ -17,8 +17,7 @@ import { Liked } from './entities/liked.entity'; import { Report } from './entities/report.entity'; import { Period, Season } from './postings.types'; import { BLOCKING_LIMIT } from './postings.constants'; -// import { StorageService } from 'src/storage/storage.service'; -import { FileService } from 'src/file/file.service'; +import { StorageService } from 'src/storage/storage.service'; import { BlockRepository } from 'src/users/block.repository'; @Injectable() @@ -29,7 +28,7 @@ export class PostingsService { private readonly postingsRepository: PostingsRepository, private readonly likedsRepository: LikedsRepository, private readonly reportsRepository: ReportsRepository, - private readonly storageService: FileService + private readonly storageService: StorageService ) {} async create(userId: string, createPostingDto: CreatePostingDto) { diff --git a/BE/src/timelines/timelines.module.ts b/BE/src/timelines/timelines.module.ts index 9ff66a1..7a0490c 100644 --- a/BE/src/timelines/timelines.module.ts +++ b/BE/src/timelines/timelines.module.ts @@ -12,16 +12,14 @@ import { PostingsRepository } from '../postings/repositories/postings.repository import { LikedsRepository } from '../postings/repositories/likeds.repository'; import { ReportsRepository } from '../postings/repositories/reports.repository'; import { postingsProviders } from '../postings/postings.providers'; -// import { StorageModule } from '../storage/storage.module'; -import { FileModule } from '../file/file.module'; +import { StorageModule } from '../storage/storage.module'; @Module({ imports: [ DatabaseModule, PostingsModule, UsersModule, - // StorageModule, - FileModule, + StorageModule, HttpModule, ], controllers: [TimelinesController], diff --git a/BE/src/timelines/timelines.service.ts b/BE/src/timelines/timelines.service.ts index 9f421aa..3b43388 100644 --- a/BE/src/timelines/timelines.service.ts +++ b/BE/src/timelines/timelines.service.ts @@ -10,8 +10,7 @@ import { CreateTimelineDto } from './dto/create-timeline.dto'; import { UpdateTimelineDto } from './dto/update-timeline.dto'; import { TimelinesRepository } from './timelines.repository'; import { Timeline } from './entities/timeline.entity'; -// import { StorageService } from '../storage/storage.service'; -import { FileService } from '../file/file.service'; +import { StorageService } from '../storage/storage.service'; import { PostingsService } from '../postings/postings.service'; import { KAKAO_KEYWORD_SEARCH, PAPAGO_URL } from './timelines.constants'; import { PostingsRepository } from '../postings/repositories/postings.repository'; @@ -22,7 +21,7 @@ export class TimelinesService { private readonly timelinesRepository: TimelinesRepository, private readonly postingsRepository: PostingsRepository, private readonly postingsService: PostingsService, - private readonly storageService: FileService, + private readonly storageService: StorageService, private readonly httpService: HttpService ) {} diff --git a/BE/src/users/users.module.ts b/BE/src/users/users.module.ts index 042dde4..a535949 100644 --- a/BE/src/users/users.module.ts +++ b/BE/src/users/users.module.ts @@ -3,13 +3,12 @@ import { UsersService } from './users.service'; import { UsersController } from './users.controller'; import { usersProvider } from './users.providers'; import { UserRepository } from './users.repository'; -// import { StorageModule } from '../storage/storage.module'; -import { FileModule } from '../file/file.module'; +import { StorageModule } from '../storage/storage.module'; import { DatabaseModule } from '../database/database.module'; import { BlockRepository } from './block.repository'; @Module({ - imports: [DatabaseModule, FileModule], + imports: [DatabaseModule, StorageModule], controllers: [UsersController], providers: [UsersService, ...usersProvider, UserRepository, BlockRepository], exports: [UserRepository, UsersService, BlockRepository], diff --git a/BE/src/users/users.service.ts b/BE/src/users/users.service.ts index 45c4406..ef963e3 100644 --- a/BE/src/users/users.service.ts +++ b/BE/src/users/users.service.ts @@ -1,7 +1,6 @@ import { BadRequestException, Injectable } from '@nestjs/common'; import { UserInfoDto } from './dto/user-info.dto'; -// import { StorageService } from 'src/storage/storage.service'; -import { FileService } from 'src/file/file.service'; +import { StorageService } from 'src/storage/storage.service'; import { UserRepository } from './users.repository'; import { CheckDuplicatedNameResponseDto } from './dto/check-duplicated-name-response.dto'; import { UpdateUserDto } from './dto/update-user.dto'; @@ -13,7 +12,7 @@ export class UsersService { constructor( private userRepository: UserRepository, private blockRepository: BlockRepository, - private readonly storageService: FileService + private readonly storageService: StorageService ) {} nameGenerator() {