Skip to content

Commit

Permalink
Merge pull request #44 from Arquisoft/PruebaConjunto
Browse files Browse the repository at this point in the history
Prueba conjunto
  • Loading branch information
uo283182 authored Apr 7, 2024
2 parents a0dc684 + 81783c7 commit 1ced735
Show file tree
Hide file tree
Showing 20 changed files with 9,793 additions and 24 deletions.
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es2a/recordservice:latest
profiles: ["dev", "prod"]
build: ./recordhistory
depends_on:
- mongodb
ports:
- "8003:8003"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/recorddb

authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es2a/authservice:latest
Expand Down Expand Up @@ -63,12 +77,14 @@ services:
- userservice
- authservice
- questionservice
- recordservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
QUESTIONS_SERVICE_URL: http://questionservice:8004
RECORD_SERVICE_URL: http://recordservice:8003
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001

Expand Down
21 changes: 19 additions & 2 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = express();
const port = 8000;

const questServiceUrl = process.env.QUESTIONS_SERVICE_URL || 'http://localhost:8004';
const questRandServiceUrl = process.env.WIKIDATA_SERVICE_URL || 'http://localhost:8003';
const recordService = process.env.RECORD_SERVICE_URL || 'http://localhost:8003';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';

Expand Down Expand Up @@ -45,14 +45,31 @@ app.post('/adduser', async (req, res) => {

app.post('/questions', async (req, res) => {
try {
// Forward the add user request to the user service
const userResponse = await axios.post(questServiceUrl+'/questions', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});

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

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

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
2 changes: 2 additions & 0 deletions recordhistory/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions recordhistory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/recordhistory

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Expose the port the app runs on
EXPOSE 8003

# Define the command to run your app
CMD ["node", "record-service.js"]
Loading

0 comments on commit 1ced735

Please sign in to comment.