Skip to content

Commit

Permalink
Merge pull request #90 from Arquisoft/bug_fixes_marco
Browse files Browse the repository at this point in the history
Corregidos Bugs correctamente
  • Loading branch information
AbelMH1 authored Apr 5, 2024
2 parents 3949f0f + 80779b7 commit 944a8ea
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
- run: npm --prefix gatewayservice ci
- run: npm --prefix questionsservice/questiongeneratorservice ci
- run: npm --prefix storeQuestionService ci
- run: npm --prefix userStatsService ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- run: npm --prefix storeQuestionService test -- --coverage
- run: npm --prefix userStatsService test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
24 changes: 19 additions & 5 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ app.use(express.json());

//Prometheus configuration
const metricsMiddleware = promBundle({includeMethod: true});

function catchAction(error, res) {
if ('response' in error && 'status' in error.response && 'data' in error.response && 'error' in error.response.data)
res.status(error.response.status).json({ error: error.response.data.error });
else if('response' in error && 'status' in error.response){
res.status(error.response.status).json({ error: 'Unknown error' });
} else {
console.log("Unknown error: " + error);
}
// } else {
// res.status(500).json({ error: 'Internal server error' });
// }
}

app.use(metricsMiddleware);

// Health check endpoint
Expand All @@ -30,7 +44,7 @@ app.post('/login', async (req, res) => {
const authResponse = await axios.post(authServiceUrl+'/login', req.body);
res.json(authResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
catchAction(error, res);
}
});

Expand All @@ -40,7 +54,7 @@ app.post('/adduser', async (req, res) => {
const userResponse = await axios.post(userServiceUrl+'/adduser', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
catchAction(error, res)
}
});

Expand All @@ -51,7 +65,7 @@ app.get('/history/games/:username', async (req, res) => {
const response = await axios.get(url);
res.json(response.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
catchAction(error, res)
}
})

Expand All @@ -60,7 +74,7 @@ app.get('/history/questions', async (req, res) => {
const response = await axios.get(storeQuestionsServiceUrl+'/history/questions');
res.json(response.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
catchAction(error, res)
}
})

Expand All @@ -69,7 +83,7 @@ app.get(`/questions`, async (req, res) => {
const response = await axios.get(questionsGeneratorServiceUrl+`/questions`);
res.json(response.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
catchAction(error, res)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ app.get('/questions', async (req, res) => {
// const questions = await Question.find()
const defaultQuestion = await getQuestions(req);

const questionsHistoryResponse = await axios.post(questionHistoryServiceUrl + '/history/questions', defaultQuestion);
try{
const questionsHistoryResponse = await axios.post(questionHistoryServiceUrl + '/history/questions', defaultQuestion);
} catch (error) {
console.error(`Error saving questions history: ${error}`);
}
res.json(defaultQuestion);
} catch (error) {
// res.status(500).json({ message: error.message })
Expand Down
6 changes: 3 additions & 3 deletions storeQuestionService/store-q-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.post('/history/question', async (req, res) => {
await newQuestion.save();
res.json(newQuestion);
} catch (error) {
res.status(400).json({ error: error.message });
res.status(400).json({ error: error.message || 'An error occurred'});
}
});

Expand Down Expand Up @@ -69,7 +69,7 @@ app.post('/history/questions', async (req, res) => {

res.json(newQuestions);
} catch (error) {
res.status(400).json({ error: error.message });
res.status(400).json({ error: error.message || 'An error occurred'});
}
});

Expand All @@ -88,7 +88,7 @@ app.get('/history/questions', async (req, res) => {
respuestas_incorrectas: ['Segovia','León','Valladolid']
}]);*/
} catch (error) {
res.status(500).json({ error: error.message });
res.status(500).json({ error: error.message || 'An error occurred'});
}
});

Expand Down
3 changes: 2 additions & 1 deletion webapp/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="theme-color" content="#f0f0f0" />
<meta name="color-scheme" content="dark">
<meta
name="description"
content="Web site created using create-react-app"
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function Button(props){

return (
<div className="border">
<div
<button
className="inner"
onClick={onClick}
onKeyDown={handleKeyDown}
Expand All @@ -20,11 +20,10 @@ function Button(props){
id={id}
value={value}
hidden={hidden}
role="button"
aria-label={text}
>
{text}
</div>
</button>
</div>
);
}
Expand Down
7 changes: 0 additions & 7 deletions webapp/src/components/FirstGame.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
button {
font-size: 20px;
width: 200px;
height: 50px;
justify-content: center;
}

.questionStructure{
border-radius: 1em;
border-width: 1px;
Expand Down
18 changes: 17 additions & 1 deletion webapp/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ code {
text-align: center;
}

button.inner {
border: none;
font-size: inherit;
}

a{
text-decoration: underline;
cursor: pointer;
Expand All @@ -169,4 +174,15 @@ input, label{

.addUser .inner{
padding: 1em 4.25em;
}
}

main input:-internal-autofill-selected{
box-shadow: none;
-webkit-box-shadow: 0 0 0px 1000px #212121 inset;
-webkit-text-fill-color: #f0f0f0;
color: #F0F0F0 !important;
}

main .css-md26zr-MuiInputBase-root-MuiOutlinedInput-root{
color: #F0F0F0 !important;
}
6 changes: 2 additions & 4 deletions webapp/src/userStats/css/Game.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
color: hsl(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%));
background: rgba(var(--label-r), var(--label-g), var(--label-b), var(--background-alpha));
border-color: hsla(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%), var(--border-alpha));
border-radius: 3%;

border-radius: 1em;
height: max-content;
margin-bottom: 1%;
}
Expand All @@ -82,8 +81,7 @@
color: hsl(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%));
background: rgba(var(--label-r), var(--label-g), var(--label-b), var(--background-alpha));
border-color: hsla(var(--label-h), calc(var(--label-s) * 1%), calc((var(--label-l) + var(--lighten-by)) * 1%), var(--border-alpha));
border-radius: 3%;

border-radius: 1em;
padding: 1%;
}

Expand Down

0 comments on commit 944a8ea

Please sign in to comment.