Updated lint errors and lint fix
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 9m31s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 5m0s
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s

This commit is contained in:
2025-07-02 16:47:35 -06:00
parent 9a23c1c05b
commit b59b42b57a
8 changed files with 28 additions and 25 deletions

View File

@ -111,7 +111,7 @@ app.get('/', (req, res) => {
}); });
// Error handler // Error handler
app.use((err, req, res, next) => { app.use((err, req, res, _next) => {
console.error('💥 Error:', err); console.error('💥 Error:', err);
res.status(500).json({ error: err.message }); res.status(500).json({ error: err.message });
}); });
@ -136,4 +136,4 @@ if (require.main === module) {
}); });
} }
module.exports = app; module.exports = app;

View File

@ -15,7 +15,7 @@ function logger(req, res, next) {
// Override res.end to capture response time and status // Override res.end to capture response time and status
const originalEnd = res.end; const originalEnd = res.end;
res.end = function (chunk, encoding) { res.end = function(chunk, encoding) {
const responseTime = Date.now() - startTime; const responseTime = Date.now() - startTime;
// Record response time histogram // Record response time histogram
@ -40,4 +40,4 @@ function logger(req, res, next) {
next(); next();
} }
module.exports = logger; module.exports = logger;

View File

@ -220,7 +220,7 @@ class MonitoringDashboard {
const container = document.getElementById('api-metrics'); const container = document.getElementById('api-metrics');
const requestCounters = data.counters.filter(c => c.name === 'http_requests_total'); const requestCounters = data.counters.filter(c => c.name === 'http_requests_total');
const responseCounters = data.counters.filter(c => c.name === 'http_responses_total'); // const _responseCounters = data.counters.filter(c => c.name === 'http_responses_total');
const durationHistograms = data.histograms.filter(h => h.name === 'http_request_duration_ms'); const durationHistograms = data.histograms.filter(h => h.name === 'http_request_duration_ms');
let html = '<div class="metrics-grid">'; let html = '<div class="metrics-grid">';
@ -303,7 +303,7 @@ class MonitoringDashboard {
updateStatus(status, text) { updateStatus(status, text) {
const indicator = document.getElementById('status-indicator'); const indicator = document.getElementById('status-indicator');
const dot = document.getElementById('status-dot'); // const _dot = document.getElementById('status-dot');
const statusText = document.getElementById('status-text'); const statusText = document.getElementById('status-text');
indicator.className = `status-indicator ${status}`; indicator.className = `status-indicator ${status}`;
@ -367,6 +367,7 @@ class MonitoringDashboard {
} }
// Global functions for buttons // Global functions for buttons
// eslint-disable-next-line no-unused-vars
async function refreshData() { async function refreshData() {
const dashboard = window.dashboard; const dashboard = window.dashboard;
if (dashboard) { if (dashboard) {
@ -374,6 +375,7 @@ async function refreshData() {
} }
} }
// eslint-disable-next-line no-unused-vars
async function testAPI() { async function testAPI() {
try { try {
const response = await fetch('/api/test'); const response = await fetch('/api/test');
@ -392,6 +394,7 @@ async function testAPI() {
} }
} }
// eslint-disable-next-line no-unused-vars
async function downloadMetrics() { async function downloadMetrics() {
try { try {
const response = await fetch('/api/metrics'); const response = await fetch('/api/metrics');
@ -419,4 +422,4 @@ async function downloadMetrics() {
// Initialize dashboard when page loads // Initialize dashboard when page loads
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
window.dashboard = new MonitoringDashboard(); window.dashboard = new MonitoringDashboard();
}); });

View File

@ -136,4 +136,4 @@ router.get('/test', (req, res) => {
}); });
}); });
module.exports = router; module.exports = router;

View File

@ -90,4 +90,4 @@ router.get('/live', (req, res) => {
}); });
}); });
module.exports = router; module.exports = router;

View File

@ -92,4 +92,4 @@ module.exports = {
recordHistogram, recordHistogram,
getMetrics, getMetrics,
resetMetrics resetMetrics
}; };

View File

@ -3,7 +3,7 @@ const app = require('../src/app');
describe('API Endpoints', () => { describe('API Endpoints', () => {
describe('GET /api/system', () => { describe('GET /api/system', () => {
it('should return system information', async () => { it('should return system information', async() => {
const response = await request(app) const response = await request(app)
.get('/api/system') .get('/api/system')
.expect(200); .expect(200);
@ -18,7 +18,7 @@ describe('API Endpoints', () => {
}); });
describe('GET /api/memory', () => { describe('GET /api/memory', () => {
it('should return memory information', async () => { it('should return memory information', async() => {
const response = await request(app) const response = await request(app)
.get('/api/memory') .get('/api/memory')
.expect(200); .expect(200);
@ -33,7 +33,7 @@ describe('API Endpoints', () => {
}); });
describe('GET /api/process', () => { describe('GET /api/process', () => {
it('should return process information', async () => { it('should return process information', async() => {
const response = await request(app) const response = await request(app)
.get('/api/process') .get('/api/process')
.expect(200); .expect(200);
@ -47,7 +47,7 @@ describe('API Endpoints', () => {
}); });
describe('GET /api/metrics', () => { describe('GET /api/metrics', () => {
it('should return application metrics', async () => { it('should return application metrics', async() => {
const response = await request(app) const response = await request(app)
.get('/api/metrics') .get('/api/metrics')
.expect(200); .expect(200);
@ -62,7 +62,7 @@ describe('API Endpoints', () => {
}); });
describe('GET /api/test', () => { describe('GET /api/test', () => {
it('should return test response', async () => { it('should return test response', async() => {
const response = await request(app) const response = await request(app)
.get('/api/test') .get('/api/test')
.expect(200); .expect(200);
@ -75,7 +75,7 @@ describe('API Endpoints', () => {
}); });
describe('Error handling', () => { describe('Error handling', () => {
it('should return 404 for unknown API endpoints', async () => { it('should return 404 for unknown API endpoints', async() => {
const response = await request(app) const response = await request(app)
.get('/api/nonexistent') .get('/api/nonexistent')
.expect(404); .expect(404);
@ -84,4 +84,4 @@ describe('API Endpoints', () => {
expect(response.body.error).toBe('Not Found'); expect(response.body.error).toBe('Not Found');
}); });
}); });
}); });

View File

@ -3,7 +3,7 @@ const app = require('../src/app');
describe('Health Check Endpoints', () => { describe('Health Check Endpoints', () => {
describe('GET /health', () => { describe('GET /health', () => {
it('should return basic health status', async () => { it('should return basic health status', async() => {
const response = await request(app) const response = await request(app)
.get('/health') .get('/health')
.expect(200); .expect(200);
@ -17,7 +17,7 @@ describe('Health Check Endpoints', () => {
}); });
describe('GET /health/detailed', () => { describe('GET /health/detailed', () => {
it('should return detailed health information', async () => { it('should return detailed health information', async() => {
const response = await request(app) const response = await request(app)
.get('/health/detailed') .get('/health/detailed')
.expect(200); .expect(200);
@ -49,7 +49,7 @@ describe('Health Check Endpoints', () => {
expect(response.body.loadAverage).toHaveLength(3); expect(response.body.loadAverage).toHaveLength(3);
}); });
it('should include version information', async () => { it('should include version information', async() => {
const response = await request(app) const response = await request(app)
.get('/health/detailed') .get('/health/detailed')
.expect(200); .expect(200);
@ -59,7 +59,7 @@ describe('Health Check Endpoints', () => {
}); });
describe('GET /health/ready', () => { describe('GET /health/ready', () => {
it('should return readiness status', async () => { it('should return readiness status', async() => {
const response = await request(app) const response = await request(app)
.get('/health/ready') .get('/health/ready')
.expect(200); .expect(200);
@ -70,7 +70,7 @@ describe('Health Check Endpoints', () => {
}); });
describe('GET /health/live', () => { describe('GET /health/live', () => {
it('should return liveness status', async () => { it('should return liveness status', async() => {
const response = await request(app) const response = await request(app)
.get('/health/live') .get('/health/live')
.expect(200); .expect(200);
@ -83,7 +83,7 @@ describe('Health Check Endpoints', () => {
}); });
describe('Health status validation', () => { describe('Health status validation', () => {
it('should return valid timestamp format', async () => { it('should return valid timestamp format', async() => {
const response = await request(app) const response = await request(app)
.get('/health') .get('/health')
.expect(200); .expect(200);
@ -93,11 +93,11 @@ describe('Health Check Endpoints', () => {
expect(timestamp.getTime()).not.toBeNaN(); expect(timestamp.getTime()).not.toBeNaN();
}); });
it('should return consistent service name across endpoints', async () => { it('should return consistent service name across endpoints', async() => {
const basicHealth = await request(app).get('/health'); const basicHealth = await request(app).get('/health');
const detailedHealth = await request(app).get('/health/detailed'); const detailedHealth = await request(app).get('/health/detailed');
expect(basicHealth.body.service).toBe(detailedHealth.body.service); expect(basicHealth.body.service).toBe(detailedHealth.body.service);
}); });
}); });
}); });