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
9 changes: 3 additions & 6 deletions src/fetch/db-layer-question-increase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Option = {
diff: 1 | -1;
};

async function testConnection(studyId: string, questionId: string) {
async function testConnection(questionId: string) {
const dummyData: IQuestionRow = JSON.parse(JSON.stringify(dummyQuestionRow))
.default[0];

Expand All @@ -16,12 +16,10 @@ async function testConnection(studyId: string, questionId: string) {
return dummyData;
}

async function fetchData(studyId: string, questionId: string) {
async function fetchData(questionId: string) {
try {
const response = await axios
.post(
`${process.env.DB_LAYER_HOST}/question/like/${studyId}/${questionId}`
)
.post(`${process.env.DB_LAYER_HOST}/question/like/${questionId}`)
.then((response) => response.data);

const { data, success } = response;
Expand All @@ -34,7 +32,6 @@ async function fetchData(studyId: string, questionId: string) {
}

export let fetchQuestion: (
studyId: string,
questionId: string
) => Promise<IQuestionRow | undefined>;

Expand Down
4 changes: 2 additions & 2 deletions src/routes/middleware/update-like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export async function updateLike(req: Request, res: Response) {
return;
}

const { questionId, roomNumber } = req.params;
const { questionId } = req.params;
const { type } = req.query;

console.log(type, questionId);

const questionData =
type === "decrease"
? await DBLayerQuestionDecrease(questionId)
: await DBLayerQuestionIncrease(roomNumber, questionId);
: await DBLayerQuestionIncrease(questionId);

if (!questionData) {
const responseJSON: FailResponse = {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ router.get(
);

/**
* @api {patch} study/:roomNumber/question/:questionId?type=increase 방의 질문의 좋아요를 변화시킴 (1개씩)
* @api {patch} /question/:questionId?type=increase 방의 질문의 좋아요를 변화시킴 (1개씩)
* @apiName IncreaseLike
* @apiGroup Question
*
Expand All @@ -37,7 +37,7 @@ router.get(
* @apiSuccess {Object} data 좋아요를 증가시킨 질문 정보
*/
router.patch(
"study/:roomNumber/question/:questionId",
"/question/:questionId",
[checkParamAndQuery("questionId").isString()],
updateLike
);
Expand Down