Skip to content

Commit

Permalink
[FEAT] 게시글 전체 조회, 신고하기 swagger 명세 (#333)
Browse files Browse the repository at this point in the history
* [FEAT] community post 전체 조회 명세

* [FEAT] community 신고 swagger 명세

* [CHORE] @route에서 ?page삭제

Co-authored-by: Hyosik Philip Joo <[email protected]>

* [CHORE] router GET /posts의communityPostListGet을 communityPostListGET으로 변경

* Rename [CHORE] communityPostCategoryGet.js to communityPostCategoryGET.js

* [CHORE] Rename communityPostListGet.js to communityPostListGET.js

* [CHORE] responseCommunityPostsListSchema->responseCommunityPostsSchema로 변경, POST report swagger.requestBody 추가

* [CHORE] 게시글 전체 조회, 카테고리 조회 request query에 limit 추가, response에 totalItemCount 추가

* [CHORE] 커뮤니티 카테고리별 게시글 조회 /community/category/:communityCategoryId 로 엔드포인트 변경

* [CHORE] 커뮤니티 게시물 신고 api에 404 에러 명세 추가

---------

Co-authored-by: Hyosik Philip Joo <[email protected]>
  • Loading branch information
yubinquitous and HYOSITIVE authored Mar 17, 2024
1 parent 30f21ba commit b552c51
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 41 deletions.
9 changes: 0 additions & 9 deletions functions/.pretterrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions functions/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
bracketSpacing: true,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
printWidth: 200,
tabWidth: 2,
};
9 changes: 9 additions & 0 deletions functions/api/routes/community/communityCategoryPostsGET.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @route GET /community/category/:communityCategoryId
* @desc 커뮤니티 카테고리별 게시글 조회
* @access Private
*/

module.exports = async (req, res) => {
const { page, limit } = req.query;
};
9 changes: 9 additions & 0 deletions functions/api/routes/community/communityPostsGET.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @route GET /community/posts
* @desc 커뮤니티 게시글 전체 조회
* @access Private
*/

module.exports = async (req, res) => {
const { page, limit } = req.query;
};
9 changes: 9 additions & 0 deletions functions/api/routes/community/communityReportPOST.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @route POST /community/report
* @desc 커뮤니티 게시글 신고
* @access Private
*/

module.exports = async (req, res) => {
const { communityPostId } = req.body;
};
118 changes: 113 additions & 5 deletions functions/api/routes/community/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ const express = require('express');
const router = express.Router();
const { checkUser } = require('../../../middlewares/auth');

router.get('/category', require('./communityCategoryGET')
/**
router.get(
'/category',
require('./communityCategoryGET'),
/**
* #swagger.summary = "커뮤니티 카테고리 전체 조회"
* #swagger.responses[200] = {
description: "커뮤니티 카테고리 조회 성공",
Expand All @@ -18,9 +20,51 @@ router.get('/category', require('./communityCategoryGET')
*/
);

router.get('/posts/:communityPostId', checkUser, require('./communityPostGET')
/**
router.get(
'/category/:communityCategoryId',
checkUser,
require('./communityCategoryPostsGET'),
/**
* #swagger.summary = "커뮤니티 카테고리별 게시글 조회"
* #swagger.parameters['page'] = {
in: 'query',
description: '페이지 번호',
type: 'number',
required: true
}
* #swagger.parameters['limit'] = {
in: 'query',
description: '페이지 당 게시글 수',
type: 'number',
required: true
}
* #swagger.responses[200] = {
description: "커뮤니티 게시글 카테고리별 조회 성공",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/responseCommunityPostsSchema"
}
}
}
}
* #swagger.responses[400]
* #swagger.responses[404]
*/
);

router.get(
'/posts/:communityPostId',
checkUser,
require('./communityPostGET'),
/**
* #swagger.summary = "커뮤니티 게시글 상세 조회"
* #swagger.parameters['communityPostId'] = {
in: 'path',
description: '커뮤니티 게시글 아이디',
type: 'number',
required: true
}
* #swagger.responses[200] = {
description: "커뮤니티 게시글 상세 조회 성공",
content: {
Expand All @@ -36,4 +80,68 @@ router.get('/posts/:communityPostId', checkUser, require('./communityPostGET')
*/
);

module.exports = router;
router.get(
'/posts',
checkUser,
require('./communityPostsGET'),
/**
* #swagger.summary = "커뮤니티 게시글 전체 조회"
* #swagger.parameters['page'] = {
in: 'query',
description: '페이지 번호',
type: 'number',
required: true
}
* #swagger.parameters['limit'] = {
in: 'query',
description: '페이지 당 게시글 수',
type: 'number',
required: true
}
* #swagger.responses[200] = {
description: "커뮤니티 게시글 전체 조회 성공",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/responseCommunityPostsSchema"
}
}
}
}
* #swagger.responses[400]
* #swagger.responses[404]
*/
);

router.post(
'/report',
checkUser,
require('./communityReportPOST'),
/**
* #swagger.summary = "커뮤니티 게시글 신고"
* #swagger.requestBody = {
required: true,
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/requestCommunityReportSchema"
}
}
}
}
* #swagger.responses[201] = {
description: "커뮤니티 게시글 신고 성공",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/responseCommunityReportSchema"
}
}
}
}
* #swagger.responses[400]
* #swagger.responses[404]
*/
);

module.exports = router;
114 changes: 87 additions & 27 deletions functions/constants/swagger/schemas/communitySchema.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,94 @@
const responseCommunityCategorySchema = {
$status: 200,
$success: true,
$message: "커뮤니티 카테고리 조회 성공",
$data: [
{
$id: 1,
$name: "UI/UX"
},
]
$status: 200,
$success: true,
$message: '커뮤니티 카테고리 조회 성공',
$data: [
{
$id: 1,
$name: 'UI/UX',
},
],
};

const responseCommunityPostsDetailSchema = {
$status: 200,
$success: true,
$message: "커뮤니티 게시글 상세 조회 성공",
$data: {
$status: 200,
$success: true,
$message: '커뮤니티 게시글 상세 조회 성공',
$data: {
$id: 1,
$nickname: '잡채',
$profileImage: 'https://s3~',
$title: '제목',
$body: '본문',
$contentUrl: 'https://naver.com',
$contentTitle: '콘텐츠 링크 제목',
$contentDescription: '콘텐츠 링크 설명',
$thumbnailUrl: 'https://content-thumbnail-image-url',
$createdAt: '2024-02-01',
},
};

const responseCommunityPostsSchema = {
$status: 200,
$success: true,
$message: '커뮤니티 게시글 전체 조회 성공',
$data: {
$posts: [
{
$id: 1,
$nickname: "잡채",
$profileImage: "https://s3~",
$title: "제목",
$body: "본문",
$contentUrl: "https://naver.com",
$contentTitle: "콘텐츠 링크 제목",
$contentDescription: "콘텐츠 링크 설명",
$thumbnailUrl: "https://content-thumbnail-image-url",
$createdAt: "2024-02-01",
},
}
$nickname: '잡채',
$profileImage: 'https://s3~',
$title: '제목1',
$body: '본문1',
$contentUrl: 'https://naver.com',
$contentTitle: '콘텐츠 링크 제목1',
$contentDescription: '콘텐츠 링크 설명1',
$thumbnailUrl: 'https://content-thumbnail-image-url1',
$createdAt: '2024-02-01',
},
{
$id: 2,
$nickname: '필립',
$profileImage: 'https://s3~',
$title: '제목2',
$body: '본문2',
$contentUrl: 'https://example2.com',
$contentTitle: '콘텐츠 링크 제목2',
$contentDescription: '콘텐츠 링크 설명2',
$thumbnailUrl: 'https://content-thumbnail-image-url2',
$createdAt: '2024-02-02',
},
{
$id: 3,
$nickname: '윱최',
$profileImage: 'https://s3~',
$title: '제목3',
$body: '본문3',
$contentUrl: 'https://example3.com',
$contentTitle: '콘텐츠 링크 제목3',
$contentDescription: '콘텐츠 링크 설명3',
$thumbnailUrl: 'https://content-thumbnail-image-url3',
$createdAt: '2024-02-03',
},
],
$totalItemCount: 3,
},
};

const responseCommunityReportSchema = {
$status: 200,
$success: true,
$message: '커뮤니티 게시글 신고 성공',
};

const requestCommunityReportSchema = {
$communityPostId: 1,
};

module.exports = {
responseCommunityCategorySchema,
responseCommunityPostsDetailSchema,
};
responseCommunityCategorySchema,
responseCommunityPostsDetailSchema,
responseCommunityPostsSchema,
responseCommunityReportSchema,
requestCommunityReportSchema,
};

0 comments on commit b552c51

Please sign in to comment.