Fix jwt-token
This commit is contained in:
@@ -2,6 +2,7 @@ const express = require('express');
|
||||
const DroneDetection = require('../models/DroneDetection');
|
||||
const Device = require('../models/Device');
|
||||
const { authenticateToken } = require('../middleware/auth');
|
||||
const { getDroneTypeInfo } = require('../utils/droneTypes');
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
@@ -66,8 +67,17 @@ router.get('/', authenticateToken, async (req, res) => {
|
||||
const hasNextPage = parseInt(page) < totalPages;
|
||||
const hasPrevPage = parseInt(page) > 1;
|
||||
|
||||
// Enhance detections with drone type information
|
||||
const enhancedDetections = detections.map(detection => {
|
||||
const droneTypeInfo = getDroneTypeInfo(detection.drone_type);
|
||||
return {
|
||||
...detection.toJSON(),
|
||||
drone_type_info: droneTypeInfo
|
||||
};
|
||||
});
|
||||
|
||||
res.json({
|
||||
detections,
|
||||
detections: enhancedDetections,
|
||||
pagination: {
|
||||
currentPage: parseInt(page),
|
||||
totalPages,
|
||||
@@ -107,7 +117,14 @@ router.get('/:id', authenticateToken, async (req, res) => {
|
||||
return res.status(404).json({ error: 'Detection not found' });
|
||||
}
|
||||
|
||||
res.json(detection);
|
||||
// Enhance detection with drone type information
|
||||
const droneTypeInfo = getDroneTypeInfo(detection.drone_type);
|
||||
const enhancedDetection = {
|
||||
...detection.toJSON(),
|
||||
drone_type_info: droneTypeInfo
|
||||
};
|
||||
|
||||
res.json(enhancedDetection);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error fetching detection:', error);
|
||||
|
||||
Reference in New Issue
Block a user