Fix jwt-token
This commit is contained in:
@@ -3,9 +3,10 @@ const router = express.Router();
|
||||
const { DroneDetection, Device, Heartbeat } = require('../models');
|
||||
const { Op } = require('sequelize');
|
||||
const { sequelize } = require('../models');
|
||||
const { authenticateToken } = require('../middleware/auth');
|
||||
|
||||
// GET /api/dashboard/overview - Get dashboard overview statistics
|
||||
router.get('/overview', async (req, res) => {
|
||||
router.get('/overview', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { hours = 24 } = req.query;
|
||||
const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||
@@ -98,7 +99,7 @@ router.get('/overview', async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/dashboard/activity - Get recent activity feed
|
||||
router.get('/activity', async (req, res) => {
|
||||
router.get('/activity', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { limit = 50, hours = 24 } = req.query;
|
||||
const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||
@@ -176,7 +177,7 @@ router.get('/activity', async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/dashboard/charts/detections - Get detection chart data
|
||||
router.get('/charts/detections', async (req, res) => {
|
||||
router.get('/charts/detections', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { hours = 24, interval = 'hour' } = req.query;
|
||||
const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||
@@ -226,7 +227,7 @@ router.get('/charts/detections', async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/dashboard/charts/devices - Get device activity chart data
|
||||
router.get('/charts/devices', async (req, res) => {
|
||||
router.get('/charts/devices', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const { hours = 24 } = req.query;
|
||||
const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||
|
||||
@@ -32,7 +32,7 @@ const updateDeviceSchema = Joi.object({
|
||||
});
|
||||
|
||||
// GET /api/devices - Get all devices
|
||||
router.get('/', async (req, res) => {
|
||||
router.get('/', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const {
|
||||
include_stats = false,
|
||||
@@ -122,7 +122,7 @@ router.get('/', async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/devices/map - Get devices with location data for map display
|
||||
router.get('/map', async (req, res) => {
|
||||
router.get('/map', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const devices = await Device.findAll({
|
||||
where: {
|
||||
@@ -182,7 +182,7 @@ router.get('/map', async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/devices/:id - Get specific device
|
||||
router.get('/:id', async (req, res) => {
|
||||
router.get('/:id', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const device = await Device.findByPk(req.params.id, {
|
||||
include: [
|
||||
@@ -321,7 +321,7 @@ router.delete('/:id', authenticateToken, async (req, res) => {
|
||||
});
|
||||
|
||||
// GET /api/devices/pending - List devices pending approval
|
||||
router.get('/pending', async (req, res) => {
|
||||
router.get('/pending', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
const pendingDevices = await Device.findAll({
|
||||
where: { is_approved: false },
|
||||
|
||||
Reference in New Issue
Block a user