29 lines
807 B
JavaScript
29 lines
807 B
JavaScript
import express from 'express';
|
|
import { MetricsService } from '../services/metrics.service.js';
|
|
|
|
const router = express.Router();
|
|
|
|
export function createMetricsRoutes(apiKey, apiRevision) {
|
|
const metricsService = new MetricsService(apiKey, apiRevision);
|
|
|
|
// Get all metrics
|
|
router.get('/', async (req, res) => {
|
|
try {
|
|
console.log('[Metrics Route] Fetching metrics');
|
|
const data = await metricsService.getMetrics();
|
|
console.log('[Metrics Route] Success:', {
|
|
count: data.data?.length || 0
|
|
});
|
|
res.json(data);
|
|
} catch (error) {
|
|
console.error('[Metrics Route] Error:', error);
|
|
res.status(500).json({
|
|
status: 'error',
|
|
message: error.message,
|
|
details: error.response?.data || null
|
|
});
|
|
}
|
|
});
|
|
|
|
return router;
|
|
}
|