Skip to content

Commit

Permalink
Merge pull request #106 from Arquisoft/dev
Browse files Browse the repository at this point in the history
Cambios semana previa a entrega
  • Loading branch information
uo285427 authored Mar 8, 2024
2 parents b3653e2 + 2b0d02f commit a649d59
Show file tree
Hide file tree
Showing 30 changed files with 6,383 additions and 273 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix questions/answerservice ci
- run: npm --prefix questions/createservice ci
- run: npm --prefix questions/generatedquestservice ci
- run: npm --prefix questions/recordservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix questions/answerservice test -- --coverage
- run: npm --prefix questions/createservice test -- --coverage
- run: npm --prefix questions/generatedquestservice test -- --coverage
- run: npm --prefix questions/recordservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand Down
84 changes: 82 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix questions/answerservice ci
- run: npm --prefix questions/createservice ci
- run: npm --prefix questions/generatedquestservice ci
- run: npm --prefix questions/recordservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix questions/answerservice test -- --coverage
- run: npm --prefix questions/createservice test -- --coverage
- run: npm --prefix questions/generatedquestservice test -- --coverage
- run: npm --prefix questions/recordservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand All @@ -35,6 +43,10 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix questions/answerservice install
- run: npm --prefix questions/createservice install
- run: npm --prefix questions/generatedquestservice install
- run: npm --prefix questions/recordservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
Expand Down Expand Up @@ -93,6 +105,74 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
docker-push-answerservice:
name: Push answer service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/answerservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/answerservice
docker-push-createservice:
name: Push create service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/createservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/createservice
docker-push-recordservice:
name: Push record service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/recordservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/recordservice
docker-push-generatedquestservice:
name: Push generated quest service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/generatedquestservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/generatedquestservice
docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -113,7 +193,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-createservice,docker-push-answerservice,docker-push-recordservice,docker-push-generatedquestservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand All @@ -124,5 +204,5 @@ jobs:
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es6b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es6b/master/.env -O .env
docker compose down
docker compose --profile prod down
docker compose --profile prod up -d
70 changes: 44 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@ services:
networks:
- mynetwork

recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/recordservice:latest
authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/authservice:latest
profiles: ["dev", "prod"]
build: ./questions/recordservice
build: ./users/authservice
depends_on:
- mongodb
ports:
- "8006:8006"
- "8002:8002"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/recorddb
MONGODB_URI: mongodb://mongodb:27017/userdb

createservice:
container_name: createservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/createservice:latest
userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/userservice:latest
profiles: ["dev", "prod"]
build: ./questions/createservice
build: ./users/userservice
depends_on:
- mongodb
ports:
- "8005:8005"
- "8001:8001"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/questiondb

MONGODB_URI: mongodb://mongodb:27017/userdb

answerservice:
container_name: answerservice-${teamname:-defaultASW}
Expand All @@ -54,34 +53,47 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/questiondb

createservice:
container_name: createservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/createservice:latest
profiles: ["dev", "prod"]
build: ./questions/createservice
depends_on:
- mongodb
ports:
- "8005:8005"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/questiondb

authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/authservice:latest
recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/recordservice:latest
profiles: ["dev", "prod"]
build: ./users/authservice
build: ./questions/recordservice
depends_on:
- mongodb
ports:
- "8002:8002"
- "8006:8006"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
MONGODB_URI: mongodb://mongodb:27017/recorddb

userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/userservice:latest
generatedquestservice:
container_name: generatedquestservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/generatedquestservice:latest
profiles: ["dev", "prod"]
build: ./users/userservice
build: ./questions/generatedquestservice
depends_on:
- mongodb
ports:
- "8001:8001"
- "8007:8007"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
MONGODB_URI: mongodb://mongodb:27017/questiondb

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
Expand All @@ -92,15 +104,21 @@ services:
- mongodb
- userservice
- authservice
- answerservice
- createservice
- recordservice
- generatedquestservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUES_SERVICE_URL: http://createservice:8005
ANSW_SERVICE_URL: http://answerservice:8004
QUES_SERVICE_URL: http://createservice:8005
REC_SERVICE_URL: http://recordservice:8006
GEN_SERVICE_URL: http://generatedquestservice:8007

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
Binary file added docs/images/08-DominioV2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/src/03_system_scope_and_context.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ de jugadas anteriores.
Dentro del historial, este le mostrará el número de partidas totales realizadas y por cada una de ellas la fecha en la que se jugó, el número de respuestas acertadas, el dinero conseguido y el tiempo total
que le llevó completarlo.

Aparte de eso también tendrán la opción de visualizar el listado completo de usuarios registrados hasta la fecha.
Aparte de eso también tendra el administrador la opción de visualizar el listado completo de usuarios registrados hasta la fecha.



Expand Down
2 changes: 1 addition & 1 deletion docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ifndef::imagesdir[:imagesdir: ../images]

=== Descripción de conceptos
==== Dominio
image::08-Dominio.jpeg["Dominio"]
image::08-DominioV2.jpeg["Dominio"]


==== Experiencia de usuario (UX)
Expand Down
39 changes: 38 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const port = 8000;
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const questionServiceUrl = process.env.QUES_SERVICE_URL || 'http://localhost:8005';
const recordServiceUrl = process.env.REC_SERVICE_URL || 'http://localhost:8006';

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -42,6 +43,14 @@ app.post('/adduser', async (req, res) => {
}
});

app.post('/addRecord', async(req, res) => {
try{
const recordResponse = await axios.post(recordServiceUrl+'/addRecord', req.body);
}catch (error){
res.status(error.response.status).json({ error: error.response.data.error });
}
});

app.post('/getQuestionBody', async (req, res) => {
try {
// Forward the add user request to the user service
Expand All @@ -52,9 +61,37 @@ app.post('/getQuestionBody', async (req, res) => {
}
});

app.post('/addQuestion', async (req, res) => {
try {
// Reenviar los datos recibidos en la solicitud POST al servicio de preguntas
const questionResponse = await axios.post(`${questionServiceUrl}/addQuestion`, req.body);
res.json(questionResponse.data);
} catch (error) {
if (error.response) {
res.status(error.response.status).json({ error: error.response.data.error });
} else {
res.status(500).json({ error: 'Error interno del servidor' });
}
}
});

app.get('/getAllUsers', async (req, res) => {
try {
// Reenviar la solicitud GET al servicio de usuarios
const usersResponse = await axios.get(`${userServiceUrl}/getAllUsers`);
res.json(usersResponse.data);
} catch (error) {
if (error.response) {
res.status(error.response.status).json({ error: error.response.data.error });
} else {
res.status(500).json({ error: 'Error interno del servidor' });
}
}
})

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
});

module.exports = server
module.exports = server
Loading

0 comments on commit a649d59

Please sign in to comment.