Skip to content

Commit

Permalink
Correciones en las URL
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Mar 11, 2024
1 parent 91ed3ae commit e5dc2a5
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 96 deletions.
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
teamname="wiq_es1a"
teamname="wiq_es1a"
AUTH_SERVICE_URL=http://localhost:8002
USER_SERVICE_URL=http://localhost:8001
QUESTION_SERVICE_URL=http://localhost:8003
AUTH_SERVICE_URL=http://localhost:8004
MONGODB_URI=mongodb://localhost:27017/userdb
180 changes: 94 additions & 86 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@ jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix questionservice 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
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix questionservice 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
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
e2e-tests:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix questionservice install
- run: npm --prefix statsservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix questionservice install
- run: npm --prefix statsservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -50,12 +50,12 @@ jobs:
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
API_URI: http://${{ secrets.DEPLOY_HOST }}:8000
with:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
API_URI: http://${{ secrets.DEPLOY_HOST }}:8000
with:
name: arquisoft/wiq_es1a/webapp
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -70,10 +70,10 @@ jobs:
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1a/authservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -87,15 +87,15 @@ jobs:
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_es1a/userservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1a/userservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
docker-push-statsservice:
name: Push stats service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -104,15 +104,15 @@ jobs:
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_es1a/statsservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: statsservice
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1a/statsservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: statsservice
docker-push-questionservice:
name: Push questions service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -121,15 +121,15 @@ jobs:
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_es1a/questionservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questionservice
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1a/questionservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questionservice
docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -138,28 +138,36 @@ jobs:
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_es1a/gatewayservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: gatewayservice
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1a/gatewayservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: gatewayservice
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questionservice, docker-push-statsservice]
needs:
[
docker-push-userservice,
docker-push-authservice,
docker-push-gatewayservice,
docker-push-webapp,
docker-push-questionservice,
docker-push-statsservice,
]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es1a/master/docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1a/master/docker-compose-deploy.override.yml
docker compose --profile prod down
docker compose --profile prod up -d
- name: Deploy over SSH
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es1a/master/docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1a/master/docker-compose-deploy.override.yml
docker compose --profile prod down
docker compose --profile prod up -d
3 changes: 1 addition & 2 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,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.QUESTION_SERVICE_URL || "http://localhost:8003";
const questionServiceUrl = process.env.QUESTION_SERVICE_URL || "http://localhost:8003";
const statsServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8004";


Expand Down
5 changes: 3 additions & 2 deletions statsservice/stats-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const axios = require('axios');
const app = express();
const port = 8004;

const userServiceUrl = process.env.USER_SERVICE_URL || "http://localhost:8001";

app.use(bodyParser.json());
app.use(cors());
Expand All @@ -17,7 +18,7 @@ app.post("/saveGame", async (req, res) => {
const { username, correctAnswers, incorrectAnswers, points, avgTime } = req.body;

// Hacer una solicitud al servicio user-service para guardar el juego
const response = await axios.post('http://localhost:8001/userSaveGame', {
const response = await axios.post(userServiceUrl + '/userSaveGame', {
username,
correctAnswers,
incorrectAnswers,
Expand All @@ -43,7 +44,7 @@ app.get("/stats", async (req, res) => {
const username = req.query.user;

// Hacer una solicitud al servicio user-service para obtener estadísticas
const response = await axios.get(`http://localhost:8001/getstats?user=${username}`);
const response = await axios.get(userServiceUrl + '/getstats?user=${username}');

res.json(response.data);
} catch (error) {
Expand Down
2 changes: 0 additions & 2 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ app.use(bodyParser.json());
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb';
mongoose.connect(mongoUri);



// Function to validate required fields in the request body
function validateRequiredFields(req, requiredFields) {
for (const field of requiredFields) {
Expand Down
6 changes: 5 additions & 1 deletion webapp/.env
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
REACT_APP_API_ENDPOINT=http://localhost:8000
REACT_APP_API_ENDPOINT=http://localhost:8000
AUTH_SERVICE_URL=http://localhost:8002
USER_SERVICE_URL=http://localhost:8001
QUESTION_SERVICE_URL=http://localhost:8003
AUTH_SERVICE_URL=http://localhost:8004
3 changes: 2 additions & 1 deletion webapp/src/pages/Bateria/Bateria.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Footer from "../../components/Footer/Footer.js";
import { Link, useNavigate } from "react-router-dom";

const JuegoPreguntas = () => {
const URL = process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000"
const [isLoading, setIsLoading] = useState(true);
const [indicePregunta, setIndicePregunta] = useState(0);
const [puntuacion, setPuntuacion] = useState(0);
Expand All @@ -15,7 +16,7 @@ const JuegoPreguntas = () => {
const navigate = useNavigate();

useEffect(() => {
fetch("http://localhost:8000/questions?tematica=all&n=9000")
fetch(URL + "/questions?tematica=all&n=9000")
.then((response) => {
if (!response.ok) {
navigate("/home?error=1");
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/pages/Clasico/Clasico.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link, useNavigate } from "react-router-dom";
import Footer from "../../components/Footer/Footer.js";

const JuegoPreguntas = () => {
const URL = process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000"
const [isLoading, setIsLoading] = useState(true);
const [indicePregunta, setIndicePregunta] = useState(0);
const [puntuacion, setPuntuacion] = useState(0);
Expand All @@ -24,7 +25,7 @@ const JuegoPreguntas = () => {
const [tiempoMedio, setTiempoMedio] = useState(0);

useEffect(() => {
fetch("http://localhost:8000/questions?tematica=all&n=10")
fetch(URL + "/questions?tematica=all&n=10")
.then((response) => {
if (!response.ok) {
navigate("/home?error=1");
Expand Down

0 comments on commit e5dc2a5

Please sign in to comment.