-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Date타입으로 반환되는 모든 값에 formatDate 함수 적용
* refactor: 불필요한 TODO, FIXME 주석 제거 * refactor: DataSource type 명시 * feat(DateUtil): formatDate함수를 모든 반환객체에 적용할 수 있는 함수 추가 * feat: Entity 컬럼 중 모든 Date타입에 formatDate 함수를 적용하여 더 나은 형태로 반환 - 시간대 적용 및 밀리초 부분 제거 - 기존의 복잡했던 코드를 더 간단히 수정 - 이로인해 불필요해진 interface 제거 * feat(categoriesRepository): 싱글톤 패턴 적용 * refactor: jwt.strategy 타입 명시 - authValidateOrNext 함수를 이용하는 controllers의 req.userInfo.id를 req.userInfo?.id와 같이 옵셔널체이닝 적용 및 수정 - 로그인으로 토큰을 받았더라도 토큰이 필요한 경우, 해당 시점에서의 사용자유효성 검사 추가 - findUserInfoByUserId 함수를 validateUserInfo 함수로 함수명 수정 및 user.validate 폴더로 이동 * refactor(TokenDecoder): decodeToken 함수를 정적(static) 메소드로 변경 - 상태 독립성, 편의성, 자원(메모리) 사용 최소화 기대 - feat: Token 에러 핸들링 추가 * feat(findUserFeedsByUserId): userId가 특정되지 않을 경우 에러 반환 * feat(findUserCommentsByUserId): userId가 특정되지 않을 경우 에러 반환 * fix(jwt.strategy): decoded.id 타입 가드에 대한 조건문 에러 수정
- Loading branch information
Showing
31 changed files
with
298 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
import { | ||
BaseEntity, | ||
CreateDateColumn, | ||
DeleteDateColumn, | ||
PrimaryGeneratedColumn, | ||
UpdateDateColumn, | ||
ValueTransformer, | ||
} from 'typeorm'; | ||
import { DateUtils } from '../utils/dateUtils'; | ||
|
||
export abstract class Base { | ||
export const transformer: ValueTransformer = { | ||
from: (value: Date) => | ||
value instanceof Date ? DateUtils.formatDate(value) : null, | ||
to: (value: Date) => value, | ||
}; | ||
|
||
export abstract class Base extends BaseEntity { | ||
@PrimaryGeneratedColumn() | ||
id!: number; | ||
|
||
@CreateDateColumn({ type: 'timestamp' }) | ||
@CreateDateColumn({ type: 'timestamp', transformer: transformer }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'timestamp' }) | ||
@UpdateDateColumn({ type: 'timestamp', transformer: transformer }) | ||
updated_at!: Date; | ||
|
||
@DeleteDateColumn({ type: 'timestamp' }) | ||
deleted_at?: Date; | ||
@DeleteDateColumn({ type: 'timestamp', transformer: transformer }) | ||
deleted_at?: Date | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.