import { Router, type IRouter } from 'express';
import { authenticate } from '../middlewares/auth.middleware.js';
import * as tenantsController from '../controllers/tenants.controller.js';

const router: IRouter = Router();

router.use(authenticate);

// Self-serve multi-tenant (el caller actúa sobre sus propias memberships)
router.get('/mine', tenantsController.getMyTenants);
router.post('/mine', tenantsController.addMyTenant);

// Admin global
router.get('/', tenantsController.getAllTenants);
router.get('/:id', tenantsController.getTenant);
router.post('/', tenantsController.createTenant);
router.put('/:id', tenantsController.updateTenant);
router.delete('/:id', tenantsController.deleteTenant);

export { router as tenantsRoutes };
