Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/router/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,38 @@ import controllers from './controllers'

const router = Router()

/**
* 디미고 계정 정보를 받아 에코를 가입합니다.
* @route POST /auth/join
* @group Auth - 인증 관련 메소드
* @returns {object} 200 - 사용자 정보
* @returns {Error} 401 - 일치하는 계정이 디미고 API에 존재하지 않습니다.
*/
router.post('/join', [
check('username').isString().not().isEmpty(),
check('password').isString().not().isEmpty()
], checkValidation, controllers.Join)

/**
* 디미고 계정 정보를 받아 에코에서의 토큰을 발행합니다.
* @route POST /auth/login
* @group Auth - 인증 관련 메소드
* @returns {object} 200 - Access 토큰과 Refresh 토큰을 반환합니다.
* @returns {Error} 401 - 일치하는 에코 계정 정보가 존재하지 않습니다.
* @returns {Error} 409 - 이미 가입된 계정입니다.
*/
router.post('/login', [
check('username').isString().not().isEmpty(),
check('password').isString().not().isEmpty()
], checkValidation, controllers.Login)

/**
* Refresh 토큰으로 새로운 Access 토큰과 Refresh 토큰을 발행합니다.
* @route POST /auth/refresh
* @group Auth - 인증 관련 메소드
* @returns {object} 200 - Access 토큰과 Refresh 토큰을 반환합니다.
* @returns {Error} 401 - 토큰이 Refresh 용이 아니거나 인증에 실패했습니다.
*/
router.post('/refresh', controllers.Refresh)

export default router
23 changes: 23 additions & 0 deletions src/router/comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,38 @@ const router = Router()

router.get('/:userId', (req, res, next) => {})

/**
* 새로운 댓글을 생성합니다
* @route POST /comment
* @group Comment - 댓글 관련 메소드
* @returns {object} 200 - 생성한 댓글을 반환합니다.
* @returns {Error} 404 - 대상 게시물이 존재하지 않습니다.
*/
router.post('/', [
check('content').isString().not().isEmpty(),
check('target').custom(isObjectId)
], checkValidation, needAuthorization, controllers.CreateComment)

/**
* 댓글을 삭제합니다.
* @route DELETE /comment/:commentId
* @group Comment - 댓글 관련 메소드
* @returns {null} 204 - 댓글이 정상적으로 삭제되었습니다.
* @returns {Error} 403 - 권한이 없습니다.
* @returns {Error} 404 - 댓글이 존재하지 않습니다.
*/
router.delete('/:commentId', [
check('commentId').custom(isObjectId)
], checkValidation, needAuthorization, controllers.DeleteComment)

/**
* 댓글을 수정합니다.
* @route PUT /comment/:commentId
* @group Comment - 댓글 관련 메소드
* @returns {null} 200 - 수정된 댓글을 반환합니다.
* @returns {Error} 403 - 권한이 없습니다.
* @returns {Error} 404 - 댓글이 존재하지 않습니다.
*/
router.put('/:commentId', [
check('commentId').custom(isObjectId),
check('content').isString().not().isEmpty()
Expand Down
14 changes: 14 additions & 0 deletions src/router/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,25 @@ router.get('/brief', (req, res, next) => {})

router.get('/start/:startPage/end/:endPage', (req, res, next) => {})

/**
* 새로운 게시물을 생성합니다
* @route POST /post
* @group Post - 게시물 관련 메소드
* @returns {object} 200 - 생성한 게시물을 반환합니다.
*/
router.post('/', [
check('title').isString().not().isEmpty(),
check('content').isString().not().isEmpty()
], checkValidation, needAuthorization, controllers.CreatePost)

/**
* 게시물을 삭제합니다.
* @route DELETE /post/:postId
* @group Post - 게시물 관련 메소드
* @returns {object} 204 - 게시물이 정상적으로 삭제되었습니다.
* @returns {Error} 403 - 권한이 없습니다.
* @returns {Error} 404 - 댓글이 존재하지 않습니다.
*/
router.delete('/:postId', needAuthorization, controllers.DeletePost)

router.put('/:postId', (req, res, next) => {})
Expand Down
16 changes: 16 additions & 0 deletions src/router/subscription/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@ import {

const router = Router()

/**
* 태그를 구독합니다
* @route POST /subscription/:tagId
* @group Subscription - 구독 관련 메소드
* @returns {object} - 생성한 구독 모델을 반환합니다.
* @returns {Error} 403 - 권한이 없습니다.
* @returns {Error} 404 - 태그가 존재하지 않습니다.
* @returns {Error} 409 - 이미 구독한 태그입니다.
*/
router.post('/:tagId', [
check('tagId').custom(isObjectId)
], checkValidation, needAuthorization, controllers.CreateSubscription)

/**
* 태그의 구독을 취소합니다
* @route DELETE /subscription/:tagId
* @group Subscription - 구독 관련 메소드
* @returns {object} 204 - 구독이 정상적으로 취소되었습니다.
* @returns {Error} 404 - 구독하지 않은 태그입니다.
*/
router.delete('/:subscriptionId', [
check('subscriptionId').custom(isObjectId)
], checkValidation, needAuthorization, controllers.CancelSubscription)
Expand Down
20 changes: 20 additions & 0 deletions src/router/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,34 @@ import {

const router = Router()

/**
* 자신이 볼 수 있는 태그를 모두 반환합니다.
* @route GET /tag
* @group Tag - 태그 관련 메소드
* @returns {object} - 모든 태그를 반환합니다.
*/
router.get('/', needAuthorization, controllers.GetAllTags)

/**
* 새로운 태그를 생성합니다.
* @route POST /tag
* @group Tag - 태그 관련 메소드
* @returns {object} - 새로운 태그를 반환합니다.
*/
router.post('/', [
check('name').isString().not().isEmpty(),
check('description').isString().not().isEmpty(),
check('joinOption').isIn(['P', 'R', 'O'])
], checkValidation, needAuthorization, controllers.CreateTag)

/**
* 태그를 삭제합니다.
* @route DELETE /tag
* @group Tag - 태그 관련 메소드
* @returns {object} 204 - 태그를 정상적으로 삭제했습니다.
* @returns {Error} 403 - 권한이 없습니다.
* @returns {Error} 404 - 존재하지 않는 태그입니다.
*/
router.delete('/:tagId', needAuthorization, controllers.DeleteTag)

router.put('/:tagId', (req, res, next) => {})
Expand Down
2 changes: 1 addition & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"produces": [
"application/json"
],
"schemes": ["https"],
"schemes": ["http", "https"],
"securityDefinitions": {
"JWT": {
"type": "apiKey",
Expand Down