Skip to content

Commit

Permalink
[FEAT] 커뮤니티 카테고리 전체 조회 API (#346)
Browse files Browse the repository at this point in the history
* [FEAT] 커뮤니티 카테고리 조회 성공 response message 추가

* [FEAT] 커뮤니티 카테고리 조회 성공 쿼리 구현

* [FEAT] 커뮤니티 카테고리 조회 성공 API 구현

* [DOCS] 잘못된 토큰 재발급 엔드포인트 주석 수정

* [CHORE] 관련 response message 복수형으로 변경
  • Loading branch information
HYOSITIVE authored Apr 1, 2024
1 parent 5e8b9b7 commit bcc58ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion functions/api/routes/auth/reissueTokenPOST.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { TOKEN_INVALID, TOKEN_EXPIRED } = require('../../../constants/jwt');
const asyncWrapper = require('../../../lib/asyncWrapper');

/**
* @route POST /auth/reissue
* @route POST /auth/token
* @desc 토큰 재발급
* @access Public
*/
Expand Down
18 changes: 16 additions & 2 deletions functions/api/routes/community/communityCategoriesGET.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
const util = require('../../../lib/util');
const statusCode = require('../../../constants/statusCode');
const responseMessage = require('../../../constants/responseMessage');
const db = require('../../../db/db');
const { communityDB } = require('../../../db');
const asyncWrapper = require('../../../lib/asyncWrapper');

/**
* @route GET /community/categories
* @desc 커뮤니티 카테고리 조회
* @access Public
*/

module.exports = async (req, res) => {
module.exports = asyncWrapper(async (req, res) => {
const dbConnection = await db.connect(req);
req.dbConnection = dbConnection;

const communityCategories = await communityDB.getCommunityCategories(dbConnection);

};
res.status(statusCode.OK).send(
util.success(statusCode.OK, responseMessage.READ_COMMUNITY_CATEGORIES_SUCCESS, communityCategories),
);
});
1 change: 1 addition & 0 deletions functions/constants/responseMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module.exports = {
// 커뮤니티
READ_COMMUNITY_POST_SUCCESS: '커뮤니티 게시글 상세 조회 성공',
NO_COMMUNITY_POST: '존재하지 않는 커뮤니티 게시글',
READ_COMMUNITY_CATEGORIES_SUCCESS: '커뮤니티 카테고리 조회 성공',

// 서버 상태 체크
HEALTH_CHECK_SUCCESS: '서버 상태 정상',
Expand Down
14 changes: 13 additions & 1 deletion functions/db/community.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ const getCommunityPostDetail = async (client, communityPostId) => {
return convertSnakeToCamel.keysToCamel(rows[0]);
};

module.exports = { getCommunityPostDetail };
const getCommunityCategories = async (client) => {
const { rows } = await client.query(
`
SELECT cc.id, cc.name
FROM community_category cc
WHERE cc.is_deleted = FALSE
`,
);

return convertSnakeToCamel.keysToCamel(rows);
};

module.exports = { getCommunityPostDetail, getCommunityCategories };

0 comments on commit bcc58ed

Please sign in to comment.