새로운 API 제안: 게시글 북마크 기능 추가
게시글을 북마크할 수 있는 API를 제안합니다. 이 기능을 통해 사용자는 나중에 다시 보고 싶은 게시글을 북마크하고 목록으로 조회할 수 있습니다.
제안된 API
-
게시글 북마크 추가
- URL:
POST /api/v1/articles/:id/bookmark
- 설명: 특정 게시글을 북마크합니다.
- 요청 본문: 없음
- 응답: 북마크 추가 성공 여부
-
북마크된 게시글 목록 조회
- URL:
GET /api/v1/articles/bookmarks
- 설명: 사용자가 북마크한 게시글 목록을 조회합니다.
- 요청 매개변수:
PaginationDto (페이지 정보)
- 응답: 북마크된 게시글 목록
API 구현 예시
@UseGuards(JwtGuard)
@Controller('api/v1/articles')
export class ArticlesController {
constructor(private readonly articlesService: ArticlesService) {}
@TypedRoute.Post(':id/bookmark')
public async bookmarkArticle(
@UserId() userId: number,
@TypedParam('id', 'number') articleId: number
): Promise<TryCatch<true, CANNOT_FINDONE_ARTICLE>> {
const article = await this.articlesService.getOneDetailArticle(userId, articleId);
if (!article) {
return typia.random<CANNOT_FINDONE_ARTICLE>();
}
await this.articlesService.bookmark(userId, articleId);
return createResponseForm(true);
}
@TypedRoute.Get('bookmarks')
public async getBookmarkedArticles(
@UserId() userId: number,
@TypedQuery() paginationDto: PaginationDto
): Promise<TryPagination<ArticleType.GetAllArticlesReponse>> {
const articlesToRead = await this.articlesService.getBookmarkedByUser(userId, paginationDto);
const response = createPaginationForm(articlesToRead, paginationDto);
return response;
}
}
이 기능이 추가되면 사용자 경험이 향상될 것으로 기대됩니다. 검토 부탁드립니다.
새로운 API 제안: 게시글 북마크 기능 추가
게시글을 북마크할 수 있는 API를 제안합니다. 이 기능을 통해 사용자는 나중에 다시 보고 싶은 게시글을 북마크하고 목록으로 조회할 수 있습니다.
제안된 API
게시글 북마크 추가
POST /api/v1/articles/:id/bookmark북마크된 게시글 목록 조회
GET /api/v1/articles/bookmarksPaginationDto(페이지 정보)API 구현 예시
이 기능이 추가되면 사용자 경험이 향상될 것으로 기대됩니다. 검토 부탁드립니다.