Fix jwt-token
This commit is contained in:
@@ -2,9 +2,12 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
const Joi = require('joi');
|
||||
const { DroneDetection, Device } = require('../models');
|
||||
const { processAlert } = require('../services/alertService');
|
||||
const AlertService = require('../services/alertService');
|
||||
const { validateRequest } = require('../middleware/validation');
|
||||
|
||||
// Initialize AlertService instance
|
||||
const alertService = new AlertService();
|
||||
|
||||
// Validation schema for drone detection
|
||||
const droneDetectionSchema = Joi.object({
|
||||
device_id: Joi.number().integer().required(),
|
||||
@@ -61,7 +64,7 @@ router.post('/', validateRequest(droneDetectionSchema), async (req, res) => {
|
||||
});
|
||||
|
||||
// Process alerts asynchronously
|
||||
processAlert(detection).catch(error => {
|
||||
alertService.processAlert(detection).catch(error => {
|
||||
console.error('Alert processing error:', error);
|
||||
});
|
||||
|
||||
|
||||
@@ -555,10 +555,5 @@ class AlertService {
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
const alertService = new AlertService();
|
||||
|
||||
module.exports = {
|
||||
processAlert: (detection) => alertService.processAlert(detection),
|
||||
AlertService
|
||||
};
|
||||
// Export the class directly (not a singleton instance)
|
||||
module.exports = AlertService;
|
||||
|
||||
Reference in New Issue
Block a user