Skip to content

Commit

Permalink
[FEAT] 커뮤니티 카테고리, 게시글 상세 조회 swagger 명세 (#331)
Browse files Browse the repository at this point in the history
* [FEAT] community swagger schema 추가

* [FEAT] community category, post 조회 swagger 명세

* [DOCS]: .gitignore 내 .vscode 추가
  • Loading branch information
jokj624 authored Mar 13, 2024
1 parent cef8e29 commit 30f21ba
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ havit-server-key.cer
AuthKey_*

# Swagger
swagger-output.json
swagger-output.json

#VSCode
.vscode
20 changes: 10 additions & 10 deletions functions/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const swaggerFile = require("../constants/swagger/swagger-output.json");
const app = express();

Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: `${process.env.NODE_ENV}_app`,
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Sentry.Integrations.Express({ app }),
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
],
tracesSampleRate: process.env.SENTRY_TRACES_SAMPLE_RATE,
dsn: process.env.SENTRY_DSN,
environment: `${process.env.NODE_ENV}_app`,
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Sentry.Integrations.Express({ app }),
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
],
tracesSampleRate: process.env.SENTRY_TRACES_SAMPLE_RATE,
});

app.use(Sentry.Handlers.requestHandler());
Expand All @@ -41,7 +41,7 @@ if (process.env.NODE_ENV === "production") {

// request에 담긴 정보를 json 형태로 파싱하기 위한 미들웨어들
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());

if (process.env.NODE_ENV === "development") {
Expand Down Expand Up @@ -72,7 +72,7 @@ module.exports = functions
})
.region("asia-northeast3") // 서버가 돌아갈 region. asia-northeast3는 서울
.https.onRequest(async (req, res) => {

// 들어오는 요청에 대한 로그를 콘솔에 찍기. 디버깅 때 유용하게 쓰일 예정.
// 콘솔에 찍고 싶은 내용을 원하는 대로 추가하면 됨. (req.headers, req.query 등)
console.log("\n\n", "[api]", `[${req.method.toUpperCase()}]`, req.originalUrl, req.body);
Expand Down
9 changes: 9 additions & 0 deletions functions/api/routes/community/communityCategoryGET.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @route GET /community/category
* @desc 커뮤니티 카테고리 조회
* @access Public
*/

module.exports = async (req, res) => {

};
9 changes: 9 additions & 0 deletions functions/api/routes/community/communityPostGET.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @route GET /community/posts/:communityPostId
* @desc 커뮤니티 게시글 상세 조회
* @access Private
*/

module.exports = async (req, res) => {

};
39 changes: 39 additions & 0 deletions functions/api/routes/community/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const express = require('express');
const router = express.Router();
const { checkUser } = require('../../../middlewares/auth');

router.get('/category', require('./communityCategoryGET')
/**
* #swagger.summary = "커뮤니티 카테고리 전체 조회"
* #swagger.responses[200] = {
description: "커뮤니티 카테고리 조회 성공",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/responseCommunityCategorySchema"
}
}
}
}
*/
);

router.get('/posts/:communityPostId', checkUser, require('./communityPostGET')
/**
* #swagger.summary = "커뮤니티 게시글 상세 조회"
* #swagger.responses[200] = {
description: "커뮤니티 게시글 상세 조회 성공",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/responseCommunityPostsDetailSchema"
}
}
}
}
* #swagger.responses[400]
* #swagger.responses[404]
*/
);

module.exports = router;
23 changes: 20 additions & 3 deletions functions/api/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const router = express.Router();

router.use(
'/content', require('./content')
'/content', require('./content')
/**
* #swagger.tags = ['content']
* #swagger.responses[500] = {
Expand All @@ -15,7 +15,7 @@ router.use(
}
}
}
*/
*/
);
router.use(
'/category', require('./category')
Expand Down Expand Up @@ -96,7 +96,7 @@ router.use(
}
}
*/

);
router.use(
'/health', require('./health')
Expand All @@ -115,4 +115,21 @@ router.use(
*/
);

router.use(
'/community', require('./community')
/**
* #swagger.tags = ['community']
* #swagger.responses[500] = {
description: "Internal Server Error",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/internalServerErrorSchema"
}
}
}
}
*/
);

module.exports = router;
3 changes: 2 additions & 1 deletion functions/config/swagger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const swaggerAutogen = require('swagger-autogen')({ openapi: '3.0.0' });
const { commonErrorSchema, noticeSchema } = require('../constants/swagger/schemas');
const { commonErrorSchema, noticeSchema, communitySchema } = require('../constants/swagger/schemas');
const dotenv = require('dotenv');
dotenv.config({ path: '.env.dev' });

Expand Down Expand Up @@ -32,6 +32,7 @@ const options = {
schemas: {
...commonErrorSchema,
...noticeSchema,
...communitySchema,
}
}
};
Expand Down
34 changes: 34 additions & 0 deletions functions/constants/swagger/schemas/communitySchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const responseCommunityCategorySchema = {
$status: 200,
$success: true,
$message: "커뮤니티 카테고리 조회 성공",
$data: [
{
$id: 1,
$name: "UI/UX"
},
]
};

const responseCommunityPostsDetailSchema = {
$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",
},
}

module.exports = {
responseCommunityCategorySchema,
responseCommunityPostsDetailSchema,
};
1 change: 1 addition & 0 deletions functions/constants/swagger/schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
commonErrorSchema: require('./commonErrorSchema'),
noticeSchema: require('./noticeSchema'),
communitySchema: require('./communitySchema'),
}

0 comments on commit 30f21ba

Please sign in to comment.