Skip to content

Commit

Permalink
Merge pull request #9 from Arquisoft/ServicioQuestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago21112001 authored Feb 11, 2024
2 parents a6ab717 + 352e951 commit a655cef
Show file tree
Hide file tree
Showing 9 changed files with 917 additions and 3 deletions.
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/userservice:latest
Expand Down Expand Up @@ -53,9 +53,18 @@ services:
networks:
- mynetwork
environment:
GENERATE_SERVICE_URL: http://questionservice:8003
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001

questionservice:
container_name: questionservice-${teamname:-defaultASW}
build: ./questionservice
ports:
- "8003:8003"
networks:
- mynetwork

webapp:
container_name: webapp-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/webapp:latest
Expand Down
16 changes: 16 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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 generateServiceURL = process.env.GENERATE_SERVICE_URL || 'http://localhost:8003';

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

app.post('/generatequestion', async(req,res)=> {
try{
// Redirige la solicitud al servicio de generación de preguntas sin enviar un cuerpo de solicitud.
const response = await axios.post(`${generateServiceURL}/generatequestion`);

// Devuelve la respuesta del servicio de generación de preguntas al cliente original.
res.json(response.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 questionservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions questionservice/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/questionservice

# 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", "question-service.js"]
Loading

0 comments on commit a655cef

Please sign in to comment.