Skip to content

Commit

Permalink
refactor: roomListGET error case 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
youngkwon02 committed Feb 17, 2022
1 parent 59d0422 commit 2116a0c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions functions/api/routes/room/roomListGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ const roomPOST = require('./roomPOST');
* @습관방_리스트_조회
* @route GET /room?lastId=&size=
* @error
* 1. 잘못된 lastId
* 1. lastId 또는 size 값이 전달되지 않음
* 2. 잘못된 lastId
*/

module.exports = async (req, res) => {
const lastId = Number(req.query.lastId);
const size = Number(req.query.size);
console.log(lastId, size);
const user = req.user;
console.log(user.userId);

// @error 1. lastId 또는 size 값이 전달되지 않음
if (!lastId || !size) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE));
}

let client;

Expand All @@ -49,7 +53,7 @@ module.exports = async (req, res) => {
// 최초 요청이 아닐시
if (lastId !== -1) {
const lastIndex = _.indexOf(roomIds, lastId);
// @error 1. 잘못된 last Id
// @error 2. 잘못된 last Id
if (lastIndex === -1) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.INVALID_LASTID));
}
Expand Down

0 comments on commit 2116a0c

Please sign in to comment.