import { Router } from 'express';
import { checkAll, checkUpdate, create, destroy, importFromTenant, index, show, update } from '../controllers/applicationController.js';
import { requireAdmin, requireAuth } from '../middleware/auth.js';

export const applicationRoutes = Router();

// Phase 5 application catalog: groups versioned deployments + tracks upstream
// version state and adoption of existing tenant apps.
applicationRoutes.get('/', requireAuth, index);
applicationRoutes.post('/', requireAuth, create);
applicationRoutes.post('/check-all', requireAuth, requireAdmin, checkAll);
applicationRoutes.post('/import', requireAuth, importFromTenant);
applicationRoutes.get('/:id', requireAuth, show);
applicationRoutes.put('/:id', requireAuth, update);
applicationRoutes.delete('/:id', requireAuth, destroy);
applicationRoutes.post('/:id/check-update', requireAuth, checkUpdate);
