diff --git a/src/common/config/jwt.config.ts b/src/common/config/jwt.config.ts index 2a182ec..2272954 100644 --- a/src/common/config/jwt.config.ts +++ b/src/common/config/jwt.config.ts @@ -5,9 +5,9 @@ export const jwtConfig: JwtModuleAsyncOptions = { inject: [ConfigService], useFactory: async (configService: ConfigService) => { return { - secret: configService.get('JWT_SECRET'), + secret: configService.get('JWT_SECRET'), signOptions: { - expiresIn: configService.get('JWT_EXPIRATION_TIME'), + expiresIn: configService.get('JWT_EXPIRATION_TIME'), }, }; }, diff --git a/src/common/config/multer.config.ts b/src/common/config/multer.config.ts index 3342f96..47d7fcf 100644 --- a/src/common/config/multer.config.ts +++ b/src/common/config/multer.config.ts @@ -1,13 +1,27 @@ import { ConfigService } from '@nestjs/config'; import { MulterModuleAsyncOptions } from '@nestjs/platform-express'; import { diskStorage } from 'multer'; +import { existsSync, mkdirSync } from 'fs'; +import { extname } from 'path'; export const multerConfig: MulterModuleAsyncOptions = { inject: [ConfigService], useFactory: async (configService: ConfigService) => { return { storage: diskStorage({ - destination: './uploads', + destination: (req, file, callback) => { + const uploadPath = __dirname + '/../../uploads'; + if (!existsSync(uploadPath)) { + // uploads 폴더가 존재하지 않을시, 생성합니다. + mkdirSync(uploadPath); + } + callback(null, uploadPath); + }, + filename: (req, file, callback) => { + const userAccessToken = 'test'; + const extension = extname(file.mimetype); + callback(null, `${userAccessToken}-${file.fieldname}.${extension}`); + }, }), }; }, diff --git a/src/common/config/typeorm.config.ts b/src/common/config/typeorm.config.ts index e11aa92..90bfe45 100644 --- a/src/common/config/typeorm.config.ts +++ b/src/common/config/typeorm.config.ts @@ -6,11 +6,11 @@ export const typeOrmConfig: TypeOrmModuleAsyncOptions = { useFactory: async (configService: ConfigService) => { return { type: 'postgres', - host: configService.get('POSTGRES_HOST'), - port: configService.get('POSTGRES_PORT'), - username: configService.get('POSTGRES_USER'), - password: configService.get('POSTGRES_PASSWORD'), - database: configService.get('POSTGRES_DB'), + host: configService.get('POSTGRES_HOST'), + port: configService.get('POSTGRES_PORT'), + username: configService.get('POSTGRES_USER'), + password: configService.get('POSTGRES_PASSWORD'), + database: configService.get('POSTGRES_DB'), entities: [__dirname + '/../../**/entities/*.entity.{js,ts}'], synchronize: true, };