// apps/api/src/routes/admin.routes.js

const express = require('express');
const router = express.Router();
const adminController = require('../controllers/admin.controller');
const authMiddleware = require('../middleware/auth.middleware');
const adminMiddleware = require('../middleware/admin.middleware');

// Global authentication & authorization gate
router.use(authMiddleware);
router.use(adminMiddleware);

// Core Dashboard Matrix
router.get('/stats', adminController.getStats);
router.get('/analytics', adminController.getAnalytics);

// Account Provisioning & Control
router.get('/users', adminController.getUsers);
router.post('/users', adminController.createUser);
router.put('/users/:id', adminController.updateUser);
router.delete('/users/:id', adminController.deleteUser);
router.put('/users/:id/role', adminController.changeUserRole);

// Signal Telemetry Pipelines
router.get('/signals', adminController.getSignals);
router.put('/signals/:id/status', adminController.updateSignalStatus);
router.delete('/signals/:id', adminController.deleteSignal);

// Data Stream Channels (Registry tracking control)
router.get('/channels', adminController.getChannels);
router.post('/channels', adminController.createChannel);
router.put('/channels/:id/status', adminController.updateChannelStatus);
router.delete('/channels/:id', adminController.deleteChannel);

// Audit Logging & Context Variables
router.get('/logs', adminController.getLogs);
router.get('/settings', adminController.getSettings);
router.put('/settings', adminController.updateSettings);

module.exports = router;