Fix jwt-token

This commit is contained in:
2025-09-10 06:13:47 +02:00
parent b0a700a6cf
commit 7877902698
6 changed files with 165 additions and 5 deletions

View File

@@ -11,7 +11,8 @@ const { getDroneTypeInfo, getDroneTypeName } = require('../utils/droneTypes');
const DEBUG_CONFIG = {
storeHeartbeats: process.env.STORE_HEARTBEATS === 'true', // Store heartbeat data for debugging
storeNoneDetections: process.env.STORE_DRONE_TYPE0 === 'true', // Store drone_type 0 for debugging
logAllDetections: process.env.LOG_ALL_DETECTIONS === 'true' // Log all detection data
logAllDetections: process.env.LOG_ALL_DETECTIONS === 'true', // Log all detection data
storeRawPayload: process.env.STORE_RAW_PAYLOAD === 'true' // Store complete raw payload for debugging
};
// Initialize services
@@ -192,12 +193,22 @@ async function handleHeartbeat(req, res) {
await device.update({ last_heartbeat: new Date() });
// Create heartbeat record with all optional fields
const heartbeat = await Heartbeat.create({
const heartbeatRecord = {
device_id: deviceId,
device_key: key,
...heartbeatData,
received_at: new Date()
});
};
// Add raw payload if debugging is enabled
if (DEBUG_CONFIG.storeRawPayload) {
heartbeatRecord.raw_payload = req.body;
if (DEBUG_CONFIG.logAllDetections) {
console.log(`🔍 Storing heartbeat raw payload for debugging: ${JSON.stringify(req.body)}`);
}
}
const heartbeat = await Heartbeat.create(heartbeatRecord);
// Emit real-time update via Socket.IO (from original heartbeat route)
req.io.emit('device_heartbeat', {
@@ -290,10 +301,20 @@ async function handleDetection(req, res) {
}
// Create detection record
const detection = await DroneDetection.create({
const detectionRecord = {
...detectionData,
server_timestamp: new Date()
});
};
// Add raw payload if debugging is enabled
if (DEBUG_CONFIG.storeRawPayload) {
detectionRecord.raw_payload = req.body;
if (DEBUG_CONFIG.logAllDetections) {
console.log(`🔍 Storing raw payload for debugging: ${JSON.stringify(req.body)}`);
}
}
const detection = await DroneDetection.create(detectionRecord);
// Process detection through tracking service for movement analysis (from original)
const movementAnalysis = droneTracker.processDetection({