Skip to content
This repository was archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
fix: async/await 관련된 메서드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JHyeok committed Jul 15, 2020
1 parent 126c1ad commit c002039
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 10 additions & 5 deletions src/services/PostService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,31 @@ export class PostService {
* @param limit limit
* @param sort best는 주간 인기글을 조회하고 best가 아니면 일반 최신글을 조회한다.
*/
public getPosts(
public async getPosts(
offset: number,
limit: number,
sort?: string,
): Promise<Post[]> {
switch (sort) {
case "best":
const dateBeforeWeek = this.getDateBeforeWeek();
return this.postRepository.getBestPosts(offset, limit, dateBeforeWeek);

return await this.postRepository.getBestPosts(
offset,
limit,
dateBeforeWeek,
);
default:
return this.postRepository.getPosts(offset, limit);
return await this.postRepository.getPosts(offset, limit);
}
}

/**
* 포스트 정보를 조회한다.
* @param postId 포스트 Id
*/
public getPostById(postId: string): Promise<Post> {
return this.postRepository.getPostById(postId);
public async getPostById(postId: string): Promise<Post> {
return await this.postRepository.getPostById(postId);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class UserService {
* 사용자 정보를 조회한다.
* @param id 사용자 Id
*/
public getUserById(id: string): Promise<User> {
return this.userRepository.findOne({
public async getUserById(id: string): Promise<User> {
return await this.userRepository.findOne({
select: ["id", "email", "realName", "createdAt"],
where: { id: id },
});
Expand All @@ -40,16 +40,16 @@ export class UserService {
* 사용자가 작성한 포스트 목록을 조회한다.
* @param userId 사용자 Id
*/
public getPostsByUserId(userId: string) {
return this.postRepository.getPostsByUserId(userId);
public async getPostsByUserId(userId: string) {
return await this.postRepository.getPostsByUserId(userId);
}

/**
* 사용자가 작성한 삭제되지 않은 댓글과 답글들을 조회한다.
* @param userId 사용자 Id
*/
public getCommentsByUserId(userId: string) {
return this.postCommentRepository.getCommentsByUserId(userId);
public async getCommentsByUserId(userId: string) {
return await this.postCommentRepository.getCommentsByUserId(userId);
}

/**
Expand Down

0 comments on commit c002039

Please sign in to comment.