Skip to content

Commit

Permalink
Merge pull request #57 from Arquisoft/generacionRespuestasAngel
Browse files Browse the repository at this point in the history
Generacion respuestas angel
  • Loading branch information
holmess23 authored Mar 14, 2024
2 parents a6f8bb8 + 037bee2 commit b331895
Show file tree
Hide file tree
Showing 18 changed files with 11,285 additions and 3 deletions.
34 changes: 33 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

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

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

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6a/gatewayservice:latest
Expand All @@ -48,13 +76,17 @@ services:
- mongodb
- userservice
- authservice
- questiongenservice
- questionaskservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
AUTH_SERVICE_URL: http://authservice:8002
QUESTION_GEN_SERVICE_URL: http://questiongenservice:8003
QUESTION_ASK_SERVICE_URL: http://questionaskservice:8004

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
24 changes: 23 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const promBundle = require('express-prom-bundle');
const app = express();
const port = 8000;

const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const questionGenServiceUrl = process.env.QUESTION_GEN_SERVICE_URL || 'http://localhost:8003';
const questionAskServiceUrl = process.env.QUESTION_ASK_SERVICE_URL || 'http://localhost:8004';

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

app.post('/addquestion', async (req, res) => {
try {
// Forward the add question request to the question generation service
const questionGenResponse = await axios.post(questionGenServiceUrl+'/addquestion', req.body);
res.json(questionGenResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});

app.post('/getquestion', async (req, res) => {
try {
// Forward the get question request to the question asking service
const questionAskResponse = await axios.post(questionAskServiceUrl+'/getquestion', req.body);
res.json(questionAskResponse.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 questions/questionaskservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions questions/questionaskservice/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/questionaskservice

# 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 8004

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

0 comments on commit b331895

Please sign in to comment.