Skip to content

Commit

Permalink
fix: use correct json response from routes
Browse files Browse the repository at this point in the history
  • Loading branch information
drodil committed Jan 17, 2024
1 parent 060c7e5 commit 5ca8149
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions plugins/qeta-backend/src/service/routes/answers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(201);
response.send(answer);
response.json(answer);
});

// POST /questions/:id/answers/:answerId
Expand Down Expand Up @@ -103,7 +103,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(201);
response.send(answer);
response.json(answer);
});

// POST /questions/:id/answers/:answerId/comments
Expand Down Expand Up @@ -159,7 +159,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(201);
response.send(answer);
response.json(answer);
},
);

Expand Down Expand Up @@ -188,7 +188,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(201);
response.send(answer);
response.json(answer);
},
);

Expand All @@ -212,7 +212,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {
mapAdditionalFields(username, answer, options, moderator);

// Response
response.send(answer);
response.json(answer);
});

// DELETE /questions/:id/answers/:answerId
Expand Down Expand Up @@ -295,7 +295,7 @@ export const answersRoutes = (router: Router, options: RouterOptions) => {
});
}
// Response
response.send(answer);
response.json(answer);
};

// GET /questions/:id/answers/:answerId/upvote
Expand Down
24 changes: 12 additions & 12 deletions plugins/qeta-backend/src/service/routes/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
const questions = await database.getQuestions(username, request.query);

// Response
response.send(questions);
response.json(questions);
});

// GET /questions
Expand Down Expand Up @@ -79,7 +79,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
});

// Response
response.send(questions);
response.json(questions);
});

// GET /questions/:id
Expand All @@ -105,7 +105,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
);

// Response
response.send(question);
response.json(question);
});

// POST /questions/:id/comments
Expand Down Expand Up @@ -153,7 +153,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
}

// Response
response.send(question);
response.json(question);
});

// DELETE /questions/:id/comments/:commentId
Expand Down Expand Up @@ -183,7 +183,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
);

// Response
response.send(question);
response.json(question);
},
);

Expand Down Expand Up @@ -221,7 +221,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
if (!validateRequestBody(request.body)) {
response
.status(400)
.send({ errors: validateRequestBody.errors, type: 'body' });
.json({ errors: validateRequestBody.errors, type: 'body' });
return;
}

Expand Down Expand Up @@ -255,7 +255,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(201);
response.send(question);
response.json(question);
});

// POST /questions/:id
Expand All @@ -265,7 +265,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
if (!validateRequestBody(request.body)) {
response
.status(400)
.send({ errors: validateRequestBody.errors, type: 'body' });
.json({ errors: validateRequestBody.errors, type: 'body' });
return;
}

Expand Down Expand Up @@ -305,7 +305,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {

// Response
response.status(200);
response.send(question);
response.json(question);
});

// DELETE /questions/:id
Expand Down Expand Up @@ -383,7 +383,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
}

// Response
response.send(question);
response.json(question);
};

// GET /questions/:id/upvote
Expand Down Expand Up @@ -419,7 +419,7 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
mapAdditionalFields(username, question, options, moderator);

// Response
response.send(question);
response.json(question);
});

// GET /questions/:id/unfavorite
Expand All @@ -445,6 +445,6 @@ export const questionsRoutes = (router: Router, options: RouterOptions) => {
mapAdditionalFields(username, question, options, moderator);

// Response
response.send(question);
response.json(question);
});
};
2 changes: 1 addition & 1 deletion plugins/qeta-backend/src/service/routes/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export const tagsRoutes = (router: Router, options: RouterOptions) => {
// GET /tags
router.get('/tags', async (_request, response) => {
const tags = await database.getTags();
response.send(tags);
response.json(tags);
});
};

0 comments on commit 5ca8149

Please sign in to comment.