Skip to content

Commit

Permalink
[MOD] 곡 상세+나의 뮤멘트 API - request-body보내지 않으면 400 핸들링 #145
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchaeeun3447 committed Feb 5, 2023
1 parent b82667b commit f10f4d0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions dist/controllers/MusicController.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/controllers/MusicController.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/routes/MusicRouter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/routes/MusicRouter.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/controllers/MusicController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ import { MusicCreateDto } from '../interfaces/music/MusicCreateDto';
* @DESC 곡 상세보기 뷰에서 music 정보와 나의 뮤멘트 정보 가져오기
*/
const getMusicAndMyMument = async (req: Request, res: Response) => {
const { musicId } = req.params;
const userId = req.body.userId;
const musicCreateDto: MusicCreateDto = req.body;

const error = validationResult(req);

if (!error.isEmpty()) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, message.WRONG_PARAMS));
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, message.BAD_REQUEST));
}

const { musicId } = req.params;
const userId = req.body.userId;
const musicCreateDto: MusicCreateDto = req.body;

try {
const data = await MusicService.getMusicAndMyMument(musicId, userId, musicCreateDto);

Expand Down
6 changes: 5 additions & 1 deletion src/routes/MusicRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const router: Router = Router();
router.get('/search', MusicController.getMusicListBySearch);

router.post('/:musicId', [
param('musicId').toInt().isInt(),
param('musicId').toInt().isInt(),
body('musicId').notEmpty(),
body('musicArtist').notEmpty(),
body('musicImage').notEmpty(),
body('musicName').notEmpty(),
], auth, MusicController.getMusicAndMyMument);

router.get('/:musicId/order', [
Expand Down

0 comments on commit f10f4d0

Please sign in to comment.