Skip to content

Commit

Permalink
update-quiz-selected also updates focus_origin
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVOiceover committed Aug 7, 2024
1 parent f73f993 commit 11292f9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployVercel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to Vercel

on:
push:
branches: ['serviceRoleKey']
branches: ['quiz_logic_origin']


jobs:
Expand Down
3 changes: 2 additions & 1 deletion src/routes/goals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ router.post('/update-quiz-selected', async (req, res) => {
const newUserGoals = goalsToCreate.map(goalId => ({
user_id: userId,
goal_id: goalId,
status: 'focused'
status: 'focused',
focus_origin: 'quiz'
}));

const { error: insertError } = await supabase
Expand Down
44 changes: 0 additions & 44 deletions src/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,48 +100,4 @@ router.delete('/:id', serviceRoleMiddleware, async (req: Request, res: Response)
}
});

// // Create user
// router.post('/', async (req, res) => {
// try {
// const { data, error } = await supabase
// .from('users')
// .insert([req.body])
// .select();
// if (error) throw new Error(error.message);
// res.status(201).json(data[0]);
// } catch (error: unknown) {
// res.status(500).json({ error: error instanceof Error ? error.message : 'An unknown error occurred' });
// }
// });

// // Update user
// router.put('/:id', async (req, res) => {
// try {
// const { data, error } = await supabase
// .from('users')
// .update(req.body)
// .eq('id', req.params.id)
// .select();
// if (error) throw new Error(error.message);
// if (data.length === 0) return res.status(404).json({ error: 'User not found' });
// res.json(data[0]);
// } catch (error: unknown) {
// res.status(500).json({ error: error instanceof Error ? error.message : 'An unknown error occurred' });
// }
// });

// // Delete user
// router.delete('/:id', async (req, res) => {
// try {
// const { error } = await supabase
// .from('users')
// .delete()
// .eq('id', req.params.id);
// if (error) throw new Error(error.message);
// res.status(204).send();
// } catch (error: unknown) {
// res.status(500).json({ error: error instanceof Error ? error.message : 'An unknown error occurred' });
// }
// });

export default router;
66 changes: 66 additions & 0 deletions tests/quiz.http
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,69 @@ Content-Type: application/json

### Delete answer
DELETE http://localhost:3000/quiz/answers/1


### REMOTE ###

### Questions Endpoints ###

### Get all questions with their answers
GET https://nisa-invest-tfb-be.vercel.app/quiz/questions-with-answers

### Get all questions
GET https://nisa-invest-tfb-be.vercel.app/quiz/questions

### Get question by id
GET https://nisa-invest-tfb-be.vercel.app/quiz/questions/1

### Create question
POST https://nisa-invest-tfb-be.vercel.app/quiz/questions
Content-Type: application/json

{
"question": "Createtdhd fghfghby me",
"created_at": "2024-08-01T10:00:00+00"
}

### Update question
PUT https://nisa-invest-tfb-be.vercel.app/quiz/questions/1
Content-Type: application/json

{
"question": "Wfsafafdsfdsfdsafdsa?"
}

### Delete question
DELETE https://nisa-invest-tfb-be.vercel.app/quiz/questions/1

### Answers Endpoints ###

### Get all answers
GET https://nisa-invest-tfb-be.vercel.app/quiz/answers

### Get answer by id
GET https://nisa-invest-tfb-be.vercel.app/quiz/answers/1

### Create answer
POST https://nisa-invest-tfb-be.vercel.app/quiz/answers
Content-Type: application/json

{
"answer_text": "Save more money",
"question_id": 1,
"goal_id": 2,
"created_at": "2024-08-01T10:00:00+00"
}

### Update answer
PUT https://nisa-invest-tfb-be.vercel.app/quiz/answers/1
Content-Type: application/json

{
"answer_text": "Invest in stocks",
"question_id": 1,
"goal_id": 16
}

### Delete answer
DELETE https://nisa-invest-tfb-be.vercel.app/quiz/answers/1

0 comments on commit 11292f9

Please sign in to comment.