14.9.1 댓글 작성하기
우선 댓글을 작성하는 기능부터 구현해봅시다. 기존에는 새 댓글을 작성하는 주소가 /comments로 되었는데, 이를 /articles/:postId/comments로 변경하여 새로 라우트를 작성해보세요.
api/comment/config/route.json
{
"routes": [
{
"method": "POST",
"path": "/articles/:postId/comments",
"handler": "comment.create",
"config": {
"policies": []
}
}
]
}
이제 이를 위한 핸들러 함수를 작성합시다. api/comment/controllers/comment.js 파일을 열어서 다음과 같이 create 핸들러를 작성하세요. 코드 상단에 'use strict'는 지워주세요.