Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store question service #50

Merged
merged 38 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0e5b801
first version of the backend for the question stororage microservice
MarcosBarrilVillaverde Feb 24, 2024
a0ad56c
Minor fix dokerfile
MarcosBarrilVillaverde Feb 24, 2024
b8eb199
Added timestampt to stored questions model
MarcosBarrilVillaverde Feb 25, 2024
b2941cf
Inicio del prototipo del almacen de preguntas
marco-qg Feb 29, 2024
bb0e886
Merge remote-tracking branch 'origin/develop' into storeQuestionService
MarcosBarrilVillaverde Mar 1, 2024
fc4b0d9
Fixes on structured of the data stored
MarcosBarrilVillaverde Mar 1, 2024
e8417a7
Avance conexión
marco-qg Mar 7, 2024
e71ea92
Unfortunately, light mode
marco-qg Mar 7, 2024
e8e7da7
added commented data for testing purpose
marco-qg Mar 7, 2024
3534e7d
Minor fixes
MarcosBarrilVillaverde Mar 8, 2024
955981c
Merge branch 'storeQuestionService' of https://github.com/Arquisoft/w…
MarcosBarrilVillaverde Mar 8, 2024
d3104ab
Minor fix
MarcosBarrilVillaverde Mar 8, 2024
0f1f85a
connection fixed, pending style improvement
marco-qg Mar 12, 2024
7fde766
commented code for testing purposes
marco-qg Mar 12, 2024
2ccfc61
Style done
marco-qg Mar 12, 2024
c0e34cc
Update storeQuestionService/store-q-service.js
MarcosBarrilVillaverde Mar 13, 2024
5c2a97c
Update storeQuestionService/store-q-service.js
MarcosBarrilVillaverde Mar 13, 2024
e1b5a7c
Update storeQuestionService/store-q-service.js
MarcosBarrilVillaverde Mar 13, 2024
419cbc7
Update package.json to delete unused dependencies
MarcosBarrilVillaverde Mar 13, 2024
4001c43
Update store-q-model.js to fix convention names
MarcosBarrilVillaverde Mar 13, 2024
62b6aba
Update store-q-service.js to fix changes in data structure
MarcosBarrilVillaverde Mar 13, 2024
edb3449
Update store-q-service.js to fix post functions route
MarcosBarrilVillaverde Mar 13, 2024
06d5a20
Update storeQuestionService/store-q-service.js to delete unecesary li…
MarcosBarrilVillaverde Mar 13, 2024
e7d1108
Update gateway-service.js added error managment to question service
MarcosBarrilVillaverde Mar 13, 2024
eef9653
Update gatewayservice/gateway-service.js fixed new route in questions
MarcosBarrilVillaverde Mar 13, 2024
a015019
Update storeQuestionService/store-q.test.js Added new route in tests
MarcosBarrilVillaverde Mar 13, 2024
e352872
Update storeQuestionService/store-q.test.js
MarcosBarrilVillaverde Mar 13, 2024
de2e940
Update storeQuestionService/store-q.test.js
MarcosBarrilVillaverde Mar 13, 2024
5d22841
Update storeQuestionService/store-q.test.js
MarcosBarrilVillaverde Mar 13, 2024
bab0682
Update storeQuestionService/store-q.test.js Added new route in tests
MarcosBarrilVillaverde Mar 13, 2024
fe390af
Update storeQuestionService/store-q.test.js Added new route in tests
MarcosBarrilVillaverde Mar 13, 2024
933ce9e
Update storeQuestionService/store-q.test.js Added new route in tests
MarcosBarrilVillaverde Mar 13, 2024
9536c6b
Update gatewayservice/gateway-service.js Added new route in tests
MarcosBarrilVillaverde Mar 13, 2024
40f0795
Update store-q.test.js fixed questions format
MarcosBarrilVillaverde Mar 13, 2024
5d91629
Deleted useless file
marco-qg Mar 13, 2024
3e40311
Fixed body-parser problem and commented mock question
marco-qg Mar 13, 2024
95b4d1b
added post history/question. It works, i ve tested it.
marco-qg Mar 13, 2024
1ae5550
Update store-q.test.js fixed
MarcosBarrilVillaverde Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ services:
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
STORE_QUESTION_SERVICE_URL: http://storequestionservice:8004

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down Expand Up @@ -99,6 +100,20 @@ services:
depends_on:
- prometheus

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


volumes:
mongodb_data:
Expand Down
19 changes: 19 additions & 0 deletions gatewayservice/gateway-service.js
MarcosBarrilVillaverde marked this conversation as resolved.
Show resolved Hide resolved
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 storeQuestionsServiceUrl = process.env.STORE_QUESTION_SERVICE_URL || 'http://localhost:8004'

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

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

app.get('/history/questions', async (req, res) => {
try {
const response = await axios.get(storeQuestionsServiceUrl+'/history/questions');
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 storeQuestionService/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions storeQuestionService/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/storequestionservice

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