Fix jwt-token
This commit is contained in:
@@ -64,6 +64,14 @@ const detectorSchema = Joi.alternatives().try(
|
|||||||
// POST /api/detectors - Unified endpoint for heartbeats and detections
|
// POST /api/detectors - Unified endpoint for heartbeats and detections
|
||||||
router.post('/', validateRequest(detectorSchema), async (req, res) => {
|
router.post('/', validateRequest(detectorSchema), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
// Log the full incoming payload for debugging
|
||||||
|
console.log('📦 Full payload received:', JSON.stringify(req.body, null, 2));
|
||||||
|
console.log('📡 Request headers:', JSON.stringify({
|
||||||
|
'user-agent': req.headers['user-agent'],
|
||||||
|
'content-type': req.headers['content-type'],
|
||||||
|
'content-length': req.headers['content-length']
|
||||||
|
}, null, 2));
|
||||||
|
|
||||||
// Determine if this is a heartbeat or detection based on payload
|
// Determine if this is a heartbeat or detection based on payload
|
||||||
if (req.body.type === 'heartbeat') {
|
if (req.body.type === 'heartbeat') {
|
||||||
return await handleHeartbeat(req, res);
|
return await handleHeartbeat(req, res);
|
||||||
@@ -89,6 +97,7 @@ async function handleHeartbeat(req, res) {
|
|||||||
const { type, key, device_id, ...heartbeatData } = req.body;
|
const { type, key, device_id, ...heartbeatData } = req.body;
|
||||||
|
|
||||||
console.log(`💓 Heartbeat received from device key: ${key}`);
|
console.log(`💓 Heartbeat received from device key: ${key}`);
|
||||||
|
console.log('💗 Complete heartbeat data:', JSON.stringify(req.body, null, 2));
|
||||||
|
|
||||||
// If device_id is not provided, try to find device by key
|
// If device_id is not provided, try to find device by key
|
||||||
let deviceId = device_id;
|
let deviceId = device_id;
|
||||||
@@ -183,6 +192,7 @@ async function handleDetection(req, res) {
|
|||||||
const detectionData = req.body;
|
const detectionData = req.body;
|
||||||
|
|
||||||
console.log(`🚁 Drone detection received from device ${detectionData.device_id}: drone_id=${detectionData.drone_id}, type=${detectionData.drone_type}, rssi=${detectionData.rssi}`);
|
console.log(`🚁 Drone detection received from device ${detectionData.device_id}: drone_id=${detectionData.drone_id}, type=${detectionData.drone_type}, rssi=${detectionData.rssi}`);
|
||||||
|
console.log('🔍 Complete detection data:', JSON.stringify(detectionData, null, 2));
|
||||||
|
|
||||||
// Check if device exists and is approved
|
// Check if device exists and is approved
|
||||||
let device = await Device.findOne({ where: { id: detectionData.device_id } });
|
let device = await Device.findOne({ where: { id: detectionData.device_id } });
|
||||||
|
|||||||
Reference in New Issue
Block a user