diff --git a/docker-compose.yml b/docker-compose.yml index ae23f7a..984edc7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,20 @@ services: - mynetwork environment: MONGODB_URI: mongodb://mongodb:27017/userdb + + questiongeneratorservice: + container_name: qgservice-${teamname:-defaultASW} + image: pelazas1/questiongenerator:latest + profiles: ["dev", "prod"] + build: ./game/qgservice + depends_on: + - mongodb + ports: + - "8003:8003" + networks: + - mynetwork + environment: + MONGODB_URI: mongodb://mongodb:27017/userdb gatewayservice: container_name: gatewayservice-${teamname:-defaultASW} @@ -55,6 +69,7 @@ services: environment: AUTH_SERVICE_URL: http://authservice:8002 USER_SERVICE_URL: http://userservice:8001 + QG_SERVICE_URL: http://qgservice:8003 webapp: container_name: webapp-${teamname:-defaultASW} diff --git a/game/qgservice/Dockerfile b/game/qgservice/Dockerfile index f43e2df..be1f759 100644 --- a/game/qgservice/Dockerfile +++ b/game/qgservice/Dockerfile @@ -2,7 +2,7 @@ FROM node:20 # Set the working directory in the container -WORKDIR /usr/src/userservice +WORKDIR /usr/src/questiongeneratorservice # Copy package.json and package-lock.json to the working directory COPY package*.json ./ @@ -14,7 +14,7 @@ RUN npm install COPY . . # Expose the port the app runs on -EXPOSE 8001 +EXPOSE 8003 # Define the command to run your app -CMD ["node", "user-service.js"] +CMD ["node", "qg-service.js"] diff --git a/game/qgservice/package-lock.json b/game/qgservice/package-lock.json index f21b26c..8d31222 100644 --- a/game/qgservice/package-lock.json +++ b/game/qgservice/package-lock.json @@ -1,11 +1,11 @@ { - "name": "userservice", + "name": "qgservice", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "userservice", + "name": "qgservice", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/game/qgservice/package.json b/game/qgservice/package.json index 690963b..d135bc3 100644 --- a/game/qgservice/package.json +++ b/game/qgservice/package.json @@ -1,10 +1,10 @@ { - "name": "userservice", + "name": "qgservice", "version": "1.0.0", - "description": "User service, in charge of handling users in the application", + "description": "Question generator service", "main": "service.js", "scripts": { - "start": "node user-service.js", + "start": "node qg-service.js", "test": "jest" }, "repository": { diff --git a/game/qgservice/qg-service.js b/game/qgservice/qg-service.js index bd65fca..6b1fb6b 100644 --- a/game/qgservice/qg-service.js +++ b/game/qgservice/qg-service.js @@ -16,6 +16,12 @@ const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; mongoose.connect(mongoUri); +app.get('/', (req, res) => { + res.json({ + "hi":"question generator" + }) +}) + /* // Function to validate required fields in the request body function validateRequiredFields(req, requiredFields) { @@ -47,7 +53,7 @@ app.post('/adduser', async (req, res) => { */ const server = app.listen(port, () => { - console.log(`User Service listening at http://localhost:${port}`); + console.log(`Question generator Service listening at http://localhost:${port}`); }); // Listen for the 'close' event on the Express.js server