Fix jwt-token
This commit is contained in:
@@ -271,6 +271,17 @@ async function handleDetection(req, res) {
|
|||||||
// Handle drone type 0 (None) - store for debugging but don't trigger alarms
|
// Handle drone type 0 (None) - store for debugging but don't trigger alarms
|
||||||
let isDebugDetection = false;
|
let isDebugDetection = false;
|
||||||
if (detectionData.drone_type === 0) {
|
if (detectionData.drone_type === 0) {
|
||||||
|
if (!DEBUG_CONFIG.storeNoneDetections) {
|
||||||
|
// When debug mode is disabled, return early for drone_type 0
|
||||||
|
console.log(`🔍 Drone type 0 detection skipped - debug mode disabled`);
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
message: 'Detection skipped - drone type 0 detections not stored when debug mode disabled',
|
||||||
|
device_id: detectionData.device_id,
|
||||||
|
debug_mode: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (DEBUG_CONFIG.logAllDetections) {
|
if (DEBUG_CONFIG.logAllDetections) {
|
||||||
console.log(`🔍 Debug: Drone type 0 (None) received from device ${detectionData.device_id} - storing for debug purposes`);
|
console.log(`🔍 Debug: Drone type 0 (None) received from device ${detectionData.device_id} - storing for debug purposes`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,6 +271,12 @@ describe('Detectors Routes', () => {
|
|||||||
|
|
||||||
describe('POST /detectors - Heartbeat Data', () => {
|
describe('POST /detectors - Heartbeat Data', () => {
|
||||||
it('should accept valid heartbeat', async () => {
|
it('should accept valid heartbeat', async () => {
|
||||||
|
const device = await createTestDevice({
|
||||||
|
id: 123,
|
||||||
|
is_approved: true,
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
|
||||||
const heartbeatData = {
|
const heartbeatData = {
|
||||||
type: 'heartbeat',
|
type: 'heartbeat',
|
||||||
key: 'device_123_key',
|
key: 'device_123_key',
|
||||||
@@ -304,9 +310,16 @@ describe('Detectors Routes', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle heartbeat with minimal data', async () => {
|
it('should handle heartbeat with minimal data', async () => {
|
||||||
|
// For numeric key, route will convert to integer, so create device with numeric ID
|
||||||
|
const device = await createTestDevice({
|
||||||
|
id: 123,
|
||||||
|
is_approved: true,
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
|
||||||
const heartbeatData = {
|
const heartbeatData = {
|
||||||
type: 'heartbeat',
|
type: 'heartbeat',
|
||||||
key: 'device_123_key'
|
key: '123' // Numeric string that will be converted to 123
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
@@ -334,6 +347,12 @@ describe('Detectors Routes', () => {
|
|||||||
it('should store heartbeat when debug enabled', async () => {
|
it('should store heartbeat when debug enabled', async () => {
|
||||||
process.env.STORE_HEARTBEATS = 'true';
|
process.env.STORE_HEARTBEATS = 'true';
|
||||||
|
|
||||||
|
const device = await createTestDevice({
|
||||||
|
id: 123,
|
||||||
|
is_approved: true,
|
||||||
|
is_active: true
|
||||||
|
});
|
||||||
|
|
||||||
const heartbeatData = {
|
const heartbeatData = {
|
||||||
type: 'heartbeat',
|
type: 'heartbeat',
|
||||||
key: 'device_123_key',
|
key: 'device_123_key',
|
||||||
|
|||||||
Reference in New Issue
Block a user