Skip to content

Commit

Permalink
Merge pull request #6 from CS3219-AY2425S1/yitong/frontend
Browse files Browse the repository at this point in the history
Frontend for question service
  • Loading branch information
dedsecrattle authored Sep 27, 2024
2 parents 84f3ba4 + 7a07003 commit 802b73f
Show file tree
Hide file tree
Showing 36 changed files with 2,980 additions and 2,702 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/bzPrOe11)

# CS3219 Project (PeerPrep) - AY2425S1

## Group: G06

### Note:
- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the development/deployment **AND** add your mentor to the individual repositories as a collaborator.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.
### Note:

- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the development/deployment **AND** add your mentor to the individual repositories as a collaborator.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.
13 changes: 5 additions & 8 deletions backend/question-service/src/routes/questionRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const router: Router = Router();

// Create a new question (POST)
router.post("/", async (req: Request, res: Response) => {
const { questionId, title, description, categories, complexity, link } =
req.body;
const { questionId, title, description, categories, complexity, link } = req.body;

try {
const newQuestion = new Question({
Expand Down Expand Up @@ -47,16 +46,15 @@ router.get("/:id", async (req: Request, res: Response) => {

// Update a question by ID (PUT)
router.put("/:id", async (req: Request, res: Response) => {
const { title, description, category, complexity } = req.body;
const { title, description, categories, complexity } = req.body;

try {
const updatedQuestion = await Question.findOneAndUpdate(
{ questionId: req.params.id },
{ title, description, category, complexity },
{ title, description, categories, complexity },
{ new: true }
);
if (!updatedQuestion)
return res.status(404).json({ error: "Question not found" });
if (!updatedQuestion) return res.status(404).json({ error: "Question not found" });
res.json(updatedQuestion);
} catch (err) {
res.status(500).json({ error: (err as Error).message });
Expand All @@ -69,8 +67,7 @@ router.delete("/:id", async (req: Request, res: Response) => {
const deletedQuestion = await Question.findOneAndDelete({
questionId: req.params.id,
});
if (!deletedQuestion)
return res.status(404).json({ error: "Question not found" });
if (!deletedQuestion) return res.status(404).json({ error: "Question not found" });
res.json({ message: "Question deleted successfully" });
} catch (err) {
res.status(500).json({ error: (err as Error).message });
Expand Down
1 change: 1 addition & 0 deletions frontend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
port=3001
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
Loading

0 comments on commit 802b73f

Please sign in to comment.