Skip to content

Commit

Permalink
correciones userservice
Browse files Browse the repository at this point in the history
  • Loading branch information
fer4github committed Apr 25, 2024
1 parent 7c850d1 commit 9b79b9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gatewayservice/monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ global:
scrape_configs:
- job_name: "example-nodejs-app"
static_configs:
- targets: ["gatewayservice-wiq5a:8000","questionservice-wiq5a:8003","userservice-wiq5a:8001","authservice-wiq5a:8002"]
- targets: ["gatewayservice-wiq5a:8000","userservice-wiq5a:8001","authservice-wiq5a:8002","questionservice-wiq5a:8003"]
6 changes: 6 additions & 0 deletions userservice/authservice/auth-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const User = require('./auth-model')
const promBundle = require('express-prom-bundle');


const app = express();
const port = 8002;
Expand All @@ -15,6 +17,10 @@ app.use(express.json());
const mongoUri = process.env.MONGODB_URI;
mongoose.connect(mongoUri);

//Prometheus configuration
const metricsMiddleware = promBundle({includeMethod: true});
app.use(metricsMiddleware);

// Function to validate required fields in the request body
function validateRequiredFields(req, requiredFields) {
for (const field of requiredFields) {
Expand Down
5 changes: 5 additions & 0 deletions userservice/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const bodyParser = require('body-parser');
const User = require('./user-model');
const promBundle = require('express-prom-bundle');

const app = express();
const port = 8001;

// Middleware to parse JSON in request body
app.use(bodyParser.json());

//Prometheus configuration
const metricsMiddleware = promBundle({includeMethod: true});
app.use(metricsMiddleware);

// Connect to MongoDB
//const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb';
const mongoUri = process.env.MONGODB_URI;
Expand Down

0 comments on commit 9b79b9c

Please sign in to comment.