import { Router, type IRouter } from 'express';
import { authenticate, authorize } from '../middlewares/auth.middleware.js';
import { tenantMiddleware } from '../middlewares/tenant.middleware.js';
import * as ctrl from '../controllers/connector.controller.js';

const router: IRouter = Router();

// Public endpoint — called by connector Docker container (no user JWT, uses HORUX_TOKEN)
router.post('/heartbeat', ctrl.heartbeat);

// Authenticated endpoints — for tenant owners managing their connector
router.get('/status', authenticate, tenantMiddleware, ctrl.status);
router.post('/provision', authenticate, tenantMiddleware, authorize('owner', 'cfo'), ctrl.provision);

export default router;
