Skip to content

Commit

Permalink
Merge pull request #58 from Arquisoft/generacionRespuestas
Browse files Browse the repository at this point in the history
Generacion respuestas
  • Loading branch information
holmess23 authored Mar 14, 2024
2 parents 5ead384 + b331895 commit f925705
Show file tree
Hide file tree
Showing 28 changed files with 17,010 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

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

109 changes: 109 additions & 0 deletions .idea/workspace.xml

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

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
24 changes: 12 additions & 12 deletions package-lock.json

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

59 changes: 59 additions & 0 deletions practicas/.idea/workspace.xml

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

12 changes: 12 additions & 0 deletions questions/SPARQLQueryDispatcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class SPARQLQueryDispatcher {
constructor( endpoint ) {
this.endpoint = endpoint;
}

query( sparqlQuery ) {
const fullUrl = this.endpoint + '?query=' + encodeURIComponent( sparqlQuery );
const headers = { 'Accept': 'application/sparql-results+json' };

return fetch( fullUrl, { headers } ).then( body => body.json() );
}
}
Loading

0 comments on commit f925705

Please sign in to comment.