Skip to content

Commit

Permalink
fix: configService.get type 지정, multer config 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatoziyun committed Nov 8, 2023
1 parent dd8dddc commit 2b0c049
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/common/config/jwt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export const jwtConfig: JwtModuleAsyncOptions = {
inject: [ConfigService],
useFactory: async (configService: ConfigService) => {
return {
secret: configService.get('JWT_SECRET'),
secret: configService.get<string>('JWT_SECRET'),
signOptions: {
expiresIn: configService.get('JWT_EXPIRATION_TIME'),
expiresIn: configService.get<string>('JWT_EXPIRATION_TIME'),
},
};
},
Expand Down
16 changes: 15 additions & 1 deletion src/common/config/multer.config.ts
Original file line number Diff line number Diff line change
@@ -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}`);
},
}),
};
},
Expand Down
10 changes: 5 additions & 5 deletions src/common/config/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('POSTGRES_HOST'),
port: configService.get<number>('POSTGRES_PORT'),
username: configService.get<string>('POSTGRES_USER'),
password: configService.get<string>('POSTGRES_PASSWORD'),
database: configService.get<string>('POSTGRES_DB'),
entities: [__dirname + '/../../**/entities/*.entity.{js,ts}'],
synchronize: true,
};
Expand Down

0 comments on commit 2b0c049

Please sign in to comment.