import { Router } from 'express';
import * as geometryTypeController from '../controllers/geometryTypeController.js';
import { extractUser, requireAdmin } from '../middleware/roleMiddleware.js';

const router = Router();

// Retrieve all types (public read for authenticated users, auto-seeds)
router.get('/', extractUser, geometryTypeController.getAllnames);

// Protected Routes (Edit Only)
router.post('/restore', extractUser, requireAdmin, geometryTypeController.restoreDefaults);
router.post('/', extractUser, requireAdmin, geometryTypeController.createType);
router.put('/:id', extractUser, requireAdmin, geometryTypeController.updateType);
router.delete('/:id', extractUser, requireAdmin, geometryTypeController.deleteType);

export default router;
